ConfigSchemaV1 extends BaseSchema implements ConvertableSchema<ConfigSchema> { @Override public ConfigSchema convert() { Map<String, Object> map = new HashMap<>(); map.put(VERSION, getVersion()); putIfNotNull(map, FLOW_CONTROLLER_PROPS_KEY, flowControllerProperties); putIfNotNull(map, CORE_PROPS_KEY, coreProperties); putIfNotNull(map, FLOWFILE_REPO_KEY, flowfileRepositoryProperties); putIfNotNull(map, CONTENT_REPO_KEY, contentRepositoryProperties); putIfNotNull(map, PROVENANCE_REPO_KEY, provenanceRepositorySchema); putIfNotNull(map, COMPONENT_STATUS_REPO_KEY, componentStatusRepositoryProperties); putIfNotNull(map, SECURITY_PROPS_KEY, securityProperties); List<ProcessorSchema> processorSchemas = getProcessorSchemas(); putListIfNotNull(map, PROCESSORS_KEY, processorSchemas); List<String> validationIssues = getValidationIssues(); putListIfNotNull(map, CONNECTIONS_KEY, getConnectionSchemas(processorSchemas, validationIssues)); putListIfNotNull(map, REMOTE_PROCESS_GROUPS_KEY, getRemoteProcessGroupSchemas()); putIfNotNull(map, PROVENANCE_REPORTING_KEY, provenanceReportingProperties); return new ConfigSchema(map, validationIssues); } ConfigSchemaV1(Map map); @Override ConfigSchema convert(); static String getUniqueId(Set<UUID> ids, String name); @Override int getVersion(); static final String REMOTE_PROCESS_GROUPS_KEY_V1; static final String FOUND_THE_FOLLOWING_DUPLICATE_PROCESSOR_NAMES; static final String FOUND_THE_FOLLOWING_DUPLICATE_CONNECTION_NAMES; static final String FOUND_THE_FOLLOWING_DUPLICATE_REMOTE_PROCESSING_GROUP_NAMES; static final String CANNOT_LOOK_UP_PROCESSOR_ID_FROM_PROCESSOR_NAME_DUE_TO_DUPLICATE_PROCESSOR_NAMES; static final int CONFIG_VERSION; static final String CONNECTION_WITH_NAME; static final String HAS_INVALID_DESTINATION_NAME; static final String HAS_INVALID_SOURCE_NAME; }
@Test public void testValid() throws IOException, SchemaLoaderException { Map<String, Object> yamlAsMap = SchemaLoader.loadYamlAsMap(ConfigSchemaTest.class.getClassLoader().getResourceAsStream("config-minimal.yml")); ConfigSchema configSchema = new ConfigSchemaV1(yamlAsMap).convert(); List<String> validationIssues = configSchema.getValidationIssues(); assertEquals(new ArrayList<>(), validationIssues); }
@Test public void testValidationIssuesFromNewer() throws IOException, SchemaLoaderException { Map<String, Object> yamlAsMap = SchemaLoader.loadYamlAsMap(ConfigSchemaTest.class.getClassLoader().getResourceAsStream("config-minimal-v2.yml")); ConfigSchema configSchema = new ConfigSchemaV1(yamlAsMap).convert(); List<String> validationIssues = configSchema.getValidationIssues(); assertNotEquals(0, validationIssues.size()); }
@Test public void testInvalidSourceAndDestinationNames() throws IOException, SchemaLoaderException { Map<String, Object> yamlAsMap = SchemaLoader.loadYamlAsMap(ConfigSchemaTest.class.getClassLoader().getResourceAsStream("config-minimal.yml")); List<Map<String, Object>> connections = (List<Map<String, Object>>) yamlAsMap.get(CommonPropertyKeys.CONNECTIONS_KEY); assertEquals(1, connections.size()); String fakeSource = "fakeSource"; String fakeDestination = "fakeDestination"; Map<String, Object> connection = connections.get(0); connection.put(ConnectionSchemaV1.SOURCE_NAME_KEY, fakeSource); connection.put(ConnectionSchemaV1.DESTINATION_NAME_KEY, fakeDestination); ConfigSchema configSchema = new ConfigSchemaV1(yamlAsMap).convert(); List<String> validationIssues = configSchema.getValidationIssues(); assertEquals(4, validationIssues.size()); assertEquals(BaseSchema.getIssueText(ConnectionSchema.DESTINATION_ID_KEY, "Connection(id: 0401b747-1dca-31c7-ab4b-cdacf7e6c44b, name: TailToSplit)", BaseSchema.IT_WAS_NOT_FOUND_AND_IT_IS_REQUIRED), validationIssues.get(0)); assertEquals(BaseSchema.getIssueText(ConnectionSchema.SOURCE_ID_KEY, "Connection(id: 0401b747-1dca-31c7-ab4b-cdacf7e6c44b, name: TailToSplit)", BaseSchema.IT_WAS_NOT_FOUND_AND_IT_IS_REQUIRED), validationIssues.get(1)); assertEquals(ConfigSchemaV1.CONNECTION_WITH_NAME + connection.get(NAME_KEY) + ConfigSchemaV1.HAS_INVALID_DESTINATION_NAME + fakeDestination, validationIssues.get(2)); assertEquals(ConfigSchemaV1.CONNECTION_WITH_NAME + connection.get(NAME_KEY) + ConfigSchemaV1.HAS_INVALID_SOURCE_NAME + fakeSource, validationIssues.get(3)); }