package com.github.aureliano.evtbridge.core.doc;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.github.aureliano.evtbridge.core.SchemaTypes;

public class YamlSchemaBuilderTest {

	@Test
	public void testBuildRoot() {
		String yaml = new YamlSchemaBuilder().build(SchemaTypes.ROOT);

		assertFalse(yaml.contains("http://json-schema.org/draft-04/schema#"));
		assertTrue(yaml.contains("Events collector configuration schema."));
		assertTrue(yaml.contains("object"));
		
		assertTrue(yaml.contains("properties:"));
		
		assertTrue(yaml.contains("  collectorId:"));
		assertTrue(yaml.contains("  metadata:"));
		assertTrue(yaml.contains("  eventsCollectorListeners:"));
		assertTrue(yaml.contains("  scheduler:"));
		assertTrue(yaml.contains("  multiThreadingEnabled:"));
		assertTrue(yaml.contains("  persistExecutionLog:"));
		assertTrue(yaml.contains("  outputConfigs:"));
		assertTrue(yaml.contains("  inputConfigs:"));
	}

	@Test
	public void testBuildScheduler() {
		String yaml = new YamlSchemaBuilder().build(SchemaTypes.SCHEDULER);

		assertTrue(yaml.contains("Scheduling execution configuration."));
		assertTrue(yaml.contains("object"));
		
		assertTrue(yaml.contains("properties:"));
		
		assertTrue(yaml.contains("  type:"));
		assertTrue(yaml.contains("    anyOf:"));
		assertTrue(yaml.contains("execute_once_at_specific_time"));
		assertTrue(yaml.contains("execute_periodically_at_specific_time"));
		assertTrue(yaml.contains("execute_periodically"));
	}

	@Test
	public void testBuildInput() {
		String yaml = new YamlSchemaBuilder().build(SchemaTypes.INPUT);

		assertTrue(yaml.contains("Input configuration."));
		assertTrue(yaml.contains("object"));
		
		assertTrue(yaml.contains("properties:"));
		
		assertTrue(yaml.contains("  type:"));
		assertTrue(yaml.contains("    anyOf:"));
		assertTrue(yaml.contains("external_command"));
		assertTrue(yaml.contains("file"));
		assertTrue(yaml.contains("file_tailer"));
		assertTrue(yaml.contains("standard"));
		assertTrue(yaml.contains("url"));
		assertTrue(yaml.contains("jdbc"));
	}
}
@@ -2116,10 +2116,510 @@
 c%22));%0A%09%7D
+%0A%0A%09@Test%0A%09public void testBuildOutput() %7B%0A%09%09String yaml = new YamlSchemaBuilder().build(SchemaTypes.OUTPUT);%0A%0A%09%09assertTrue(yaml.contains(%22Output configuration.%22));%0A%09%09assertTrue(yaml.contains(%22object%22));%0A%09%09%0A%09%09assertTrue(yaml.contains(%22properties:%22));%0A%09%09%0A%09%09assertTrue(yaml.contains(%22  type:%22));%0A%09%09assertTrue(yaml.contains(%22    anyOf:%22));%0A%09%09assertTrue(yaml.contains(%22file%22));%0A%09%09assertTrue(yaml.contains(%22elastic_search%22));%0A%09%09assertTrue(yaml.contains(%22standard%22));%0A%09%09assertTrue(yaml.contains(%22jdbc%22));%0A%09%7D
 %0A%7D

Add method to build yaml output schema.