JobNodeConfigurationGenerator { static void validateJobConfigs(Map<String, String> originalConfig, Map<String, String> generatedConfig) { String userConfiguredJobId = originalConfig.get(JobConfig.JOB_ID); String userConfiguredJobName = originalConfig.get(JobConfig.JOB_NAME); String generatedJobId = generatedConfig.get(JobConfig.JOB_ID); String generatedJobName = generatedConfig.get(JobConfig.JOB_NAME); if (generatedJobName != null && userConfiguredJobName != null && !StringUtils.equals(generatedJobName, userConfiguredJobName)) { throw new SamzaException(String.format( "Generated job.name = %s from app.name = %s does not match user configured job.name = %s, please configure job.name same as app.name", generatedJobName, originalConfig.get(ApplicationConfig.APP_NAME), userConfiguredJobName)); } if (generatedJobId != null && userConfiguredJobId != null && !StringUtils.equals(generatedJobId, userConfiguredJobId)) { throw new SamzaException(String.format( "Generated job.id = %s from app.id = %s does not match user configured job.id = %s, please configure job.id same as app.id", generatedJobId, originalConfig.get(ApplicationConfig.APP_ID), userConfiguredJobId)); } }    }
@Test(expected = SamzaException.class) public void testJobNameConfigValidation() { ImmutableMap<String, String> userConfigs = ImmutableMap.of("job.name", "samza-job", "job.id", "1", "app.name", "samza-app"); ImmutableMap<String, String> generatedConfigs = ImmutableMap.of("job.name", "samza-app", "job.id", "1", "app.name", "samza-app"); JobNodeConfigurationGenerator.validateJobConfigs(userConfigs, generatedConfigs); }
@Test(expected = SamzaException.class) public void testJobIdConfigValidation() { ImmutableMap<String, String> userConfigs = ImmutableMap.of("job.id", "1", "app.id", "this-should-take-precedence", "app.name", "samza-app"); ImmutableMap<String, String> generatedConfigs = ImmutableMap.of("job.name", "samza-app", "job.id", "this-should-take-precedence", "app.name", "samza-app"); JobNodeConfigurationGenerator.validateJobConfigs(userConfigs, generatedConfigs); }