ConnectionSchemaV1 extends BaseSchema implements ConvertableSchema<ConnectionSchema> { @Override public ConnectionSchema convert() { Map<String, Object> map = new HashMap<>(); map.put(NAME_KEY, name); if (StringUtil.isNullOrEmpty(sourceRelationshipName)) { map.put(SOURCE_RELATIONSHIP_NAMES_KEY, new ArrayList<>()); } else { map.put(SOURCE_RELATIONSHIP_NAMES_KEY, new ArrayList<>(Arrays.asList(sourceRelationshipName))); } map.put(MAX_WORK_QUEUE_SIZE_KEY, maxWorkQueueSize); map.put(MAX_WORK_QUEUE_DATA_SIZE_KEY, maxWorkQueueDataSize); map.put(FLOWFILE_EXPIRATION__KEY, flowfileExpiration); map.put(QUEUE_PRIORITIZER_CLASS_KEY, queuePrioritizerClass); return new ConnectionSchema(map); } ConnectionSchemaV1(Map map); @Override ConnectionSchema convert(); String getSourceName(); String getDestinationName(); String getName(); @Override int getVersion(); static final String SOURCE_RELATIONSHIP_NAME_KEY; static final String DESTINATION_NAME_KEY; static final String SOURCE_NAME_KEY; }
@Test public void testSourceRelationShipName() { ConnectionSchemaV1 schema = createSchema(0); List<String> sourceRelationshipNames = schema.convert().getSourceRelationshipNames(); assertEquals(1, sourceRelationshipNames.size()); assertEquals(testSourceRelationship, sourceRelationshipNames.get(0)); }
@Test public void testNoSourceRelationshipName() { Map<String, Object> map = createMap(); map.remove(ConnectionSchemaV1.SOURCE_RELATIONSHIP_NAME_KEY); ConnectionSchemaV1 schema = createSchema(map, 1); List<String> sourceRelationshipNames = schema.convert().getSourceRelationshipNames(); assertEquals(0, sourceRelationshipNames.size()); }
@Test public void testMaxWorkQueueSize() { assertEquals(testMaxWorkQueueSize, createSchema(0).convert().getMaxWorkQueueSize()); }
@Test public void testNoMaxWorkQueueSize() { Map<String, Object> map = createMap(); map.remove(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY); assertEquals(ConnectionSchema.DEFAULT_MAX_WORK_QUEUE_SIZE, createSchema(map, 0).convert().getMaxWorkQueueSize()); }
@Test public void testMaxWorkQueueDataSize() { assertEquals(testMaxWorkQueueDataSize, createSchema(0).convert().getMaxWorkQueueDataSize()); }
@Test public void testNoMaxWorkQueueDataSize() { Map<String, Object> map = createMap(); map.remove(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY); assertEquals(ConnectionSchema.DEFAULT_MAX_QUEUE_DATA_SIZE, createSchema(map, 0).convert().getMaxWorkQueueDataSize()); }
@Test public void testFlowFileExpiration() { assertEquals(testFlowfileExpiration, createSchema(0).convert().getFlowfileExpiration()); }
@Test public void testNoFlowFileExpiration() { Map<String, Object> map = createMap(); map.remove(ConnectionSchema.FLOWFILE_EXPIRATION__KEY); assertEquals(ConnectionSchema.DEFAULT_FLOWFILE_EXPIRATION, createSchema(map, 0).convert().getFlowfileExpiration()); }
@Test public void testQueuePrioritizer() { assertEquals(testQueuePrioritizerClass, createSchema(0).convert().getQueuePrioritizerClass()); }
@Test public void testNoQueuePrioritizer() { Map<String, Object> map = createMap(); map.remove(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY); assertEquals("", createSchema(map, 0).convert().getQueuePrioritizerClass()); }
@Test public void testConnectionGeneratedIds() { List<Map<String, Object>> listWithKeyValues = getListWithKeyValues(CommonPropertyKeys.NAME_KEY, "test", "test", "test_2", "test", "test_2"); ConfigSchema configSchema = new ConfigSchemaV1(Collections.singletonMap(CommonPropertyKeys.CONNECTIONS_KEY, listWithKeyValues)).convert(); assertMessageDoesNotExist(configSchema, ConfigSchema.FOUND_THE_FOLLOWING_DUPLICATE_CONNECTION_IDS); List<ConnectionSchema> connections = configSchema.getProcessGroupSchema().getConnections(); assertEquals(5, connections.size()); assertEquals("098f6bcd-4621-3373-8ade-4e832627b4f6", connections.get(0).getId()); assertEquals("098f6bcd-4621-3373-8ade-4e832627b4f7", connections.get(1).getId()); assertEquals("b9dacbc6-7962-39a9-9e45-394e2cf0dbf6", connections.get(2).getId()); assertEquals("098f6bcd-4621-3373-8ade-4e832627b4f8", connections.get(3).getId()); assertEquals("b9dacbc6-7962-39a9-9e45-394e2cf0dbf7", connections.get(4).getId()); }