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

import static org.junit.Assert.assertTrue;

import org.junit.Test;

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

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\""));
	}

	@Test
	public void testExecutePeriodicallyScheduler() {
		String json = new JsonSchemaBuilder().build(SchedulerTypes.EXECUTE_PERIODICALLY);

		assertTrue(json.contains("http://json-schema.org/draft-04/schema#"));
		assertTrue(json.contains("Schedule a task to execute periodically"));
		assertTrue(json.contains("object"));
		
		assertTrue(json.contains("  \"properties\" : {"));
		
		assertTrue(json.contains("\"delay\""));
		assertTrue(json.contains("\"period\""));
		assertTrue(json.contains("\"timeUnit\""));
	}

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

		assertTrue(json.contains("http://json-schema.org/draft-04/schema#"));
		assertTrue(json.contains("Input configuration."));
		assertTrue(json.contains("object"));
		
		assertTrue(json.contains("  \"properties\" : {"));
		
		assertTrue(json.contains("    \"type\" : {"));
		assertTrue(json.contains("      \"anyOf\" : ["));
		assertTrue(json.contains("\"external_command\""));
		assertTrue(json.contains("\"file\""));
		assertTrue(json.contains("\"file_tailer\""));
		assertTrue(json.contains("\"standard\""));
		assertTrue(json.contains("\"url\""));
		assertTrue(json.contains("\"jdbc\""));
	}

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

		assertTrue(json.contains("http://json-schema.org/draft-04/schema#"));
		assertTrue(json.contains("Output configuration."));
		assertTrue(json.contains("object"));
		
		assertTrue(json.contains("  \"properties\" : {"));
		
		assertTrue(json.contains("    \"type\" : {"));
		assertTrue(json.contains("      \"anyOf\" : ["));
		assertTrue(json.contains("\"file\""));
		assertTrue(json.contains("\"standard\""));
		assertTrue(json.contains("\"jdbc\""));
		assertTrue(json.contains("\"elastic_search\""));
	}
}
@@ -2230,32 +2230,494 @@
 eUnit%5C%22%22));%0A%09%7D%0A%0A
+%09@Test%0A%09public void testExecuteOnceAtSpecificTimeScheduler() %7B%0A%09%09String json = new JsonSchemaBuilder().build(SchedulerTypes.EXECUTE_ONCE_AT_SPECIFIC_TIME);%0A%0A%09%09assertTrue(json.contains(%22http://json-schema.org/draft-04/schema#%22));%0A%09%09assertTrue(json.contains(%22Schedule a task to a exute at specified date time.%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%22startupTime%5C%22%22));%0A%09%7D%0A%0A
 %09@Test%0A%09public v

Build execute once at specific time scheduler json schema.