@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 testISDConfigsWithDefaults() { GenericSystemDescriptor mySystem = new GenericSystemDescriptor("input-system", "factory.class.name") .withSystemConfigs(Collections.emptyMap()) .withDefaultStreamConfigs(Collections.emptyMap()); DoubleSerde streamSerde = new DoubleSerde(); GenericInputDescriptor<Double> isd = mySystem.getInputDescriptor("input-stream", streamSerde); Map<String, String> generatedConfigs = isd.toConfig(); Map<String, String> expectedConfigs = ImmutableMap.of("streams.input-stream.samza.system", "input-system"); assertEquals(expectedConfigs, generatedConfigs); assertEquals(streamSerde, isd.getSerde()); assertFalse(isd.getTransformer().isPresent()); }
@Before public void setUp() { defaultSerde = KVSerde.of(new StringSerde(), new JsonSerdeV2<>()); inputSystemDescriptor = new GenericSystemDescriptor("input-system", "mockSystemFactoryClassName"); outputSystemDescriptor = new GenericSystemDescriptor("output-system", "mockSystemFactoryClassName"); intermediateSystemDescriptor = new GenericSystemDescriptor("intermediate-system", "mockSystemFactoryClassName"); input1Descriptor = inputSystemDescriptor.getInputDescriptor("input1", defaultSerde); input2Descriptor = inputSystemDescriptor.getInputDescriptor("input2", defaultSerde); outputDescriptor = outputSystemDescriptor.getOutputDescriptor("output", defaultSerde); intermediateInputDescriptor = intermediateSystemDescriptor.getInputDescriptor("jobName-jobId-partition_by-p1", defaultSerde) .withPhysicalName("jobName-jobId-partition_by-p1"); intermediateOutputDescriptor = intermediateSystemDescriptor.getOutputDescriptor("jobName-jobId-partition_by-p1", defaultSerde) .withPhysicalName("jobName-jobId-partition_by-p1"); broadcastInputDesriptor = intermediateSystemDescriptor.getInputDescriptor("jobName-jobId-broadcast-b1", defaultSerde) .withPhysicalName("jobName-jobId-broadcast-b1"); Map<String, String> configs = new HashMap<>(); configs.put(JobConfig.JOB_NAME(), "jobName"); configs.put(JobConfig.JOB_ID(), "jobId"); configs.putAll(input1Descriptor.toConfig()); configs.putAll(input2Descriptor.toConfig()); configs.putAll(outputDescriptor.toConfig()); configs.putAll(inputSystemDescriptor.toConfig()); configs.putAll(outputSystemDescriptor.toConfig()); configs.putAll(intermediateSystemDescriptor.toConfig()); configs.put(JobConfig.JOB_DEFAULT_SYSTEM(), intermediateSystemDescriptor.getSystemName()); mockConfig = spy(new MapConfig(configs)); mockStreamAppDesc = new StreamApplicationDescriptorImpl(getRepartitionJoinStreamApplication(), mockConfig); }