@Test public void getCharacterReplacementMap() { assertEquals(Collections.emptyMap(), this.replaceCharacterEntityNameValidationConfiguration.getCharacterReplacementMap()); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_FORBIDDENCHARACTERS), eq(List.class))) .thenReturn(Collections.singletonList("/")); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_REPLACEMENTCHARACTERS), eq(List.class))) .thenReturn(Collections.emptyList()); assertEquals(Collections.singletonMap("/", ""), this.replaceCharacterEntityNameValidationConfiguration.getCharacterReplacementMap()); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_FORBIDDENCHARACTERS), eq(List.class))) .thenReturn(Arrays.asList("/",".","foo")); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_REPLACEMENTCHARACTERS), eq(List.class))) .thenReturn(Arrays.asList("-","-","bar")); Map<String, String> expectedMap = new HashMap<>(); expectedMap.put("/", "-"); expectedMap.put(".", "-"); expectedMap.put("foo", "bar"); assertEquals(expectedMap, this.replaceCharacterEntityNameValidationConfiguration.getCharacterReplacementMap()); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_FORBIDDENCHARACTERS), eq(List.class))) .thenReturn(Arrays.asList("/","\\","","foo")); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_REPLACEMENTCHARACTERS), eq(List.class))) .thenReturn(Arrays.asList("-","-")); expectedMap = new HashMap<>(); expectedMap.put("/", "-"); expectedMap.put("\\", "-"); expectedMap.put("foo", ""); assertEquals(expectedMap, this.replaceCharacterEntityNameValidationConfiguration.getCharacterReplacementMap()); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_FORBIDDENCHARACTERS), eq(List.class))) .thenReturn(Arrays.asList("/","\\","","/")); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_REPLACEMENTCHARACTERS), eq(List.class))) .thenReturn(Arrays.asList("-","-")); expectedMap = new HashMap<>(); expectedMap.put("/", ""); expectedMap.put("\\", "-"); assertEquals(expectedMap, this.replaceCharacterEntityNameValidationConfiguration.getCharacterReplacementMap()); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_FORBIDDENCHARACTERS), eq(List.class))) .thenReturn(Arrays.asList("/","\\","","/")); when(configurationSource .getProperty(eq(ReplaceCharacterEntityNameValidationConfiguration.PROPERTY_KEY_REPLACEMENTCHARACTERS), eq(List.class))) .thenReturn(Arrays.asList("-","-")); expectedMap = new HashMap<>(); expectedMap.put("/", ""); expectedMap.put("\\", "-"); assertEquals(expectedMap, this.replaceCharacterEntityNameValidationConfiguration.getCharacterReplacementMap()); }
public Map<String, String> getCharacterReplacementMap() { Map<String, String> result = new HashMap<>(); List<String> forbiddenCharacters = getForbiddenCharacters(); List<String> replacementCharacters = getReplacementCharacters(); if (forbiddenCharacters != null && !forbiddenCharacters.isEmpty()) { int replacementCharactersLength = (replacementCharacters != null) ? replacementCharacters.size() : 0; for (int i = 0; i < forbiddenCharacters.size(); i++) { if (!StringUtils.isEmpty(forbiddenCharacters.get(i))) { String replacementCharacter; if (i >= replacementCharactersLength) { replacementCharacter = ""; } else { replacementCharacter = replacementCharacters.get(i); } result.put(forbiddenCharacters.get(i), replacementCharacter); } } } return result; }
ReplaceCharacterEntityNameValidationConfiguration { public Map<String, String> getCharacterReplacementMap() { Map<String, String> result = new HashMap<>(); List<String> forbiddenCharacters = getForbiddenCharacters(); List<String> replacementCharacters = getReplacementCharacters(); if (forbiddenCharacters != null && !forbiddenCharacters.isEmpty()) { int replacementCharactersLength = (replacementCharacters != null) ? replacementCharacters.size() : 0; for (int i = 0; i < forbiddenCharacters.size(); i++) { if (!StringUtils.isEmpty(forbiddenCharacters.get(i))) { String replacementCharacter; if (i >= replacementCharactersLength) { replacementCharacter = ""; } else { replacementCharacter = replacementCharacters.get(i); } result.put(forbiddenCharacters.get(i), replacementCharacter); } } } return result; } }
ReplaceCharacterEntityNameValidationConfiguration { public Map<String, String> getCharacterReplacementMap() { Map<String, String> result = new HashMap<>(); List<String> forbiddenCharacters = getForbiddenCharacters(); List<String> replacementCharacters = getReplacementCharacters(); if (forbiddenCharacters != null && !forbiddenCharacters.isEmpty()) { int replacementCharactersLength = (replacementCharacters != null) ? replacementCharacters.size() : 0; for (int i = 0; i < forbiddenCharacters.size(); i++) { if (!StringUtils.isEmpty(forbiddenCharacters.get(i))) { String replacementCharacter; if (i >= replacementCharactersLength) { replacementCharacter = ""; } else { replacementCharacter = replacementCharacters.get(i); } result.put(forbiddenCharacters.get(i), replacementCharacter); } } } return result; }  }
ReplaceCharacterEntityNameValidationConfiguration { public Map<String, String> getCharacterReplacementMap() { Map<String, String> result = new HashMap<>(); List<String> forbiddenCharacters = getForbiddenCharacters(); List<String> replacementCharacters = getReplacementCharacters(); if (forbiddenCharacters != null && !forbiddenCharacters.isEmpty()) { int replacementCharactersLength = (replacementCharacters != null) ? replacementCharacters.size() : 0; for (int i = 0; i < forbiddenCharacters.size(); i++) { if (!StringUtils.isEmpty(forbiddenCharacters.get(i))) { String replacementCharacter; if (i >= replacementCharactersLength) { replacementCharacter = ""; } else { replacementCharacter = replacementCharacters.get(i); } result.put(forbiddenCharacters.get(i), replacementCharacter); } } } return result; }  Map<String, String> getCharacterReplacementMap(); }
ReplaceCharacterEntityNameValidationConfiguration { public Map<String, String> getCharacterReplacementMap() { Map<String, String> result = new HashMap<>(); List<String> forbiddenCharacters = getForbiddenCharacters(); List<String> replacementCharacters = getReplacementCharacters(); if (forbiddenCharacters != null && !forbiddenCharacters.isEmpty()) { int replacementCharactersLength = (replacementCharacters != null) ? replacementCharacters.size() : 0; for (int i = 0; i < forbiddenCharacters.size(); i++) { if (!StringUtils.isEmpty(forbiddenCharacters.get(i))) { String replacementCharacter; if (i >= replacementCharactersLength) { replacementCharacter = ""; } else { replacementCharacter = replacementCharacters.get(i); } result.put(forbiddenCharacters.get(i), replacementCharacter); } } } return result; }  Map<String, String> getCharacterReplacementMap();  }