@Test public void testISDConfigsWithOverrides() { GenericSystemDescriptor mySystem = new GenericSystemDescriptor("input-system", "factory.class.name") .withSystemConfigs(Collections.emptyMap()) .withDefaultStreamConfigs(Collections.emptyMap()); GenericInputDescriptor<Double> isd = mySystem.getInputDescriptor("input-stream", new DoubleSerde()) .withPhysicalName("physical-name") .shouldBootstrap() .isBounded() .shouldDeleteCommittedMessages() .withOffsetDefault(SystemStreamMetadata.OffsetType.OLDEST) .withPriority(12) .shouldResetOffset() .withStreamConfigs(ImmutableMap.of("custom-config-key", "custom-config-value")); Map<String, String> generatedConfigs = isd.toConfig(); Map<String, String> expectedConfigs = new HashMap<>(); expectedConfigs.put("streams.input-stream.samza.system", "input-system"); expectedConfigs.put("streams.input-stream.samza.physical.name", "physical-name"); expectedConfigs.put("streams.input-stream.samza.bootstrap", "true"); expectedConfigs.put("streams.input-stream.samza.bounded", "true"); expectedConfigs.put("streams.input-stream.samza.delete.committed.messages", "true"); expectedConfigs.put("streams.input-stream.samza.reset.offset", "true"); expectedConfigs.put("streams.input-stream.samza.offset.default", "oldest"); expectedConfigs.put("streams.input-stream.samza.priority", "12"); expectedConfigs.put("streams.input-stream.custom-config-key", "custom-config-value"); assertEquals(expectedConfigs, generatedConfigs); }
@Test public void testAPIUsage() { // does not assert anything, but acts as a compile-time check on expected descriptor type parameters // and validates that the method calls can be chained. GenericSystemDescriptor mySystem = new GenericSystemDescriptor("input-system", "factory.class.name") .withSystemConfigs(Collections.emptyMap()) .withDefaultStreamConfigs(Collections.emptyMap()); GenericInputDescriptor<Integer> input1 = mySystem.getInputDescriptor("input1", new IntegerSerde()); GenericOutputDescriptor<Integer> output1 = mySystem.getOutputDescriptor("output1", new IntegerSerde()); input1 .withPhysicalName("input-1") .shouldBootstrap() .withOffsetDefault(SystemStreamMetadata.OffsetType.NEWEST) .withPriority(1) .shouldResetOffset() .isBounded() .shouldDeleteCommittedMessages() .withStreamConfigs(Collections.emptyMap()); output1 .withPhysicalName("output-1") .withStreamConfigs(Collections.emptyMap()); }