@Test public void assignWrongCountryCodes_ShouldAssignWrongCountryCodesOnlyToWrongOnes_WhenCalledWithSeveralScenarios() { List<String> countryCodes = Arrays.asList("be", "cn", "de", "hk", "nl"); final List<Scenario> scenarios = Arrays.asList( new Scenario() .withCountryCodes("nl"), new Scenario() .withCountryCodes("nonexitent"), new Scenario() .withCountryCodes("de,AA,ZZ")); cut.assignWrongCountryCodes(countryCodes, scenarios); assertThat(scenarios).hasSize(3); assertThat(scenarios.get(2).getWrongCountryCodes()).isEqualTo("AA,ZZ"); assertThat(scenarios.get(1).getWrongCountryCodes()).isEqualTo("nonexitent"); assertThat(scenarios.get(0).getWrongCountryCodes()).isNull(); }
public void assignWrongCountryCodes(List<String> countryCodes, List<Scenario> scenarios) { for (Scenario scenario : scenarios) { StringBuilder builder = new StringBuilder(); for (String countryCode : scenario.getCountryCodes().split(Scenario.COUNTRY_CODES_SEPARATOR)) { if (!countryCodes.contains(countryCode)) { builder.append(builder.length() == 0 ? "" : ",").append(countryCode); } } scenario.setWrongCountryCodes(builder.length() == 0 ? null : builder.toString()); } }
ScenarioUploader { public void assignWrongCountryCodes(List<String> countryCodes, List<Scenario> scenarios) { for (Scenario scenario : scenarios) { StringBuilder builder = new StringBuilder(); for (String countryCode : scenario.getCountryCodes().split(Scenario.COUNTRY_CODES_SEPARATOR)) { if (!countryCodes.contains(countryCode)) { builder.append(builder.length() == 0 ? "" : ",").append(countryCode); } } scenario.setWrongCountryCodes(builder.length() == 0 ? null : builder.toString()); } } }
ScenarioUploader { public void assignWrongCountryCodes(List<String> countryCodes, List<Scenario> scenarios) { for (Scenario scenario : scenarios) { StringBuilder builder = new StringBuilder(); for (String countryCode : scenario.getCountryCodes().split(Scenario.COUNTRY_CODES_SEPARATOR)) { if (!countryCodes.contains(countryCode)) { builder.append(builder.length() == 0 ? "" : ",").append(countryCode); } } scenario.setWrongCountryCodes(builder.length() == 0 ? null : builder.toString()); } }  }
ScenarioUploader { public void assignWrongCountryCodes(List<String> countryCodes, List<Scenario> scenarios) { for (Scenario scenario : scenarios) { StringBuilder builder = new StringBuilder(); for (String countryCode : scenario.getCountryCodes().split(Scenario.COUNTRY_CODES_SEPARATOR)) { if (!countryCodes.contains(countryCode)) { builder.append(builder.length() == 0 ? "" : ",").append(countryCode); } } scenario.setWrongCountryCodes(builder.length() == 0 ? null : builder.toString()); } }  void processUploadedContent(long projectId, String sourceCode, Technology expectedTechnology, ScenarioListSupplier scenarioExtractor); void assignWrongSeverityCode(List<String> severityCodes, List<Scenario> scenarios); void assignWrongCountryCodes(List<String> countryCodes, List<Scenario> scenarios); }
ScenarioUploader { public void assignWrongCountryCodes(List<String> countryCodes, List<Scenario> scenarios) { for (Scenario scenario : scenarios) { StringBuilder builder = new StringBuilder(); for (String countryCode : scenario.getCountryCodes().split(Scenario.COUNTRY_CODES_SEPARATOR)) { if (!countryCodes.contains(countryCode)) { builder.append(builder.length() == 0 ? "" : ",").append(countryCode); } } scenario.setWrongCountryCodes(builder.length() == 0 ? null : builder.toString()); } }  void processUploadedContent(long projectId, String sourceCode, Technology expectedTechnology, ScenarioListSupplier scenarioExtractor); void assignWrongSeverityCode(List<String> severityCodes, List<Scenario> scenarios); void assignWrongCountryCodes(List<String> countryCodes, List<Scenario> scenarios);  }