@Test public void testGetStreamPropertiesPassthrough() { Config config = buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME(), TEST_PHYSICAL_NAME, StreamConfig.SYSTEM(), TEST_SYSTEM, "systemProperty1", "systemValue1", "systemProperty2", "systemValue2", "systemProperty3", "systemValue3"); StreamSpec spec = StreamUtil.getStreamSpec(STREAM_ID, new StreamConfig(config)); Map<String, String> properties = spec.getConfig(); assertEquals(3, properties.size()); assertEquals("systemValue1", properties.get("systemProperty1")); assertEquals("systemValue2", properties.get("systemProperty2")); assertEquals("systemValue3", properties.get("systemProperty3")); assertEquals("systemValue1", spec.get("systemProperty1")); assertEquals("systemValue2", spec.get("systemProperty2")); assertEquals("systemValue3", spec.get("systemProperty3")); }
@Test public void testGetStreamSamzaPropertiesOmitted() { Config config = buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME(), TEST_PHYSICAL_NAME, StreamConfig.SYSTEM(), TEST_SYSTEM, "systemProperty1", "systemValue1", "systemProperty2", "systemValue2", "systemProperty3", "systemValue3"); StreamSpec spec = StreamUtil.getStreamSpec(STREAM_ID, new StreamConfig(config)); Map<String, String> properties = spec.getConfig(); assertEquals(3, properties.size()); assertNull(properties.get(String.format(StreamConfig.PHYSICAL_NAME_FOR_STREAM_ID(), STREAM_ID))); assertNull(properties.get(String.format(StreamConfig.SYSTEM_FOR_STREAM_ID(), STREAM_ID))); assertNull(spec.get(String.format(StreamConfig.PHYSICAL_NAME_FOR_STREAM_ID(), STREAM_ID))); assertNull(spec.get(String.format(StreamConfig.SYSTEM_FOR_STREAM_ID(), STREAM_ID))); }
@Test public void testUnsupportedConfigStrippedFromProperties() { StreamSpec original = new StreamSpec("dummyId","dummyPhysicalName", "dummySystemName", ImmutableMap.of("segment.bytes", "4", "replication.factor", "7")); // First verify the original assertEquals("7", original.get("replication.factor")); assertEquals("4", original.get("segment.bytes")); Map<String, String> config = original.getConfig(); assertEquals("7", config.get("replication.factor")); assertEquals("4", config.get("segment.bytes")); // Now verify the Kafka spec KafkaStreamSpec spec = KafkaStreamSpec.fromSpec(original); assertNull(spec.get("replication.factor")); assertEquals("4", spec.get("segment.bytes")); Properties kafkaProperties = spec.getProperties(); Map<String, String> kafkaConfig = spec.getConfig(); assertNull(kafkaProperties.get("replication.factor")); assertEquals("4", kafkaProperties.get("segment.bytes")); assertNull(kafkaConfig.get("replication.factor")); assertEquals("4", kafkaConfig.get("segment.bytes")); }