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

import static org.junit.Assert.assertTrue;

import org.junit.Test;

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

public class JsonSchemaBuilderTest {

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

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

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

		assertTrue(json.contains("http://json-schema.org/draft-04/schema#"));
		assertTrue(json.contains("Scheduling execution configuration."));
		assertTrue(json.contains("object"));
		
		assertTrue(json.contains("  \"properties\" : {"));
		
		assertTrue(json.contains("    \"type\" : {"));
		assertTrue(json.contains("      \"anyOf\" : ["));
		assertTrue(json.contains("\"execute_once_at_specific_time\""));
		assertTrue(json.contains("\"execute_periodically_at_specific_time\""));
		assertTrue(json.contains("\"execute_periodically\""));
	}
}
@@ -1650,10 +1650,712 @@
 %22%22));%0A%09%7D
+%0A%0A%09@Test%0A%09public void testBuildInput() %7B%0A%09%09String json = new JsonSchemaBuilder().build(SchemaTypes.INPUT);%0A%0A%09%09assertTrue(json.contains(%22http://json-schema.org/draft-04/schema#%22));%0A%09%09assertTrue(json.contains(%22Input configuration.%22));%0A%09%09assertTrue(json.contains(%22object%22));%0A%09%09%0A%09%09assertTrue(json.contains(%22  %5C%22properties%5C%22 : %7B%22));%0A%09%09%0A%09%09assertTrue(json.contains(%22    %5C%22type%5C%22 : %7B%22));%0A%09%09assertTrue(json.contains(%22      %5C%22anyOf%5C%22 : %5B%22));%0A%09%09assertTrue(json.contains(%22%5C%22external_command%5C%22%22));%0A%09%09assertTrue(json.contains(%22%5C%22file%5C%22%22));%0A%09%09assertTrue(json.contains(%22%5C%22file_tailer%5C%22%22));%0A%09%09assertTrue(json.contains(%22%5C%22standard%5C%22%22));%0A%09%09assertTrue(json.contains(%22%5C%22url%5C%22%22));%0A%09%09assertTrue(json.contains(%22%5C%22jdbc%5C%22%22));%0A%09%7D
 %0A%7D

Add method to build json schema input.