### Question:
ParameterMapValidator implements ConstraintValidator<ParameterMap, Map<String, ClientExpressionContainer>>,
        ValidationErrorDescriptorBuilder { @Override public boolean isValid(Map<String, ClientExpressionContainer> targetParameterMap, ConstraintValidatorContext context) { if (targetParameterMap != null) { for (String paramEl : targetParameterMap.keySet()) { if (paramEl == null || paramEl.contains(".") || NOT_A_TO_Z_OR_UNDERSCORE_PATTERN.matcher(paramEl.substring(0, 1)).matches() || NOT_W_PATTERN.matcher(paramEl).find()) { return false; } } } return true; }  @Override void initialize(ParameterMap constraintAnnotation); @Override boolean isValid(Map<String, ClientExpressionContainer> targetParameterMap, ConstraintValidatorContext context); @Override ErrorDescriptor build(ConstraintViolation violation); static Pattern NOT_W_PATTERN; static Pattern NOT_A_TO_Z_OR_UNDERSCORE_PATTERN; }### Answer:
@Test public void isValid_nullMap_true() { ConstraintValidatorContext stub = mock(ConstraintValidatorContext.class); boolean isValid = objectUnderTests.isValid(null, stub); assertTrue(isValid); verifyZeroInteractions(stub); }
@Test public void isValid_emptyMap_true() { ConstraintValidatorContext stub = mock(ConstraintValidatorContext.class); Map<String, ClientExpressionContainer> map = new HashMap<String, ClientExpressionContainer>(); boolean isValid = objectUnderTests.isValid(map, stub); assertTrue(isValid); verifyZeroInteractions(stub); }
@Test public void isValid_mapWithKeyIsNull_false() { ConstraintValidatorContext stub = mock(ConstraintValidatorContext.class); Map<String, ClientExpressionContainer> map = new HashMap<String, ClientExpressionContainer>(); map.put(null, null); boolean isValid = objectUnderTests.isValid(map, stub); assertFalse(isValid); verifyZeroInteractions(stub); }
@Test public void isValid_mapWithKeyContainsDot_false() { ConstraintValidatorContext stub = mock(ConstraintValidatorContext.class); Map<String, ClientExpressionContainer> map = new HashMap<String, ClientExpressionContainer>(); map.put(".", null); boolean isValid = objectUnderTests.isValid(map, stub); assertFalse(isValid); verifyZeroInteractions(stub); }
@Test public void isValid_paramNameStartWithUnderscore_false() { assertTrue(objectUnderTests.isValid(Collections.singletonMap("_test", null), null)); }
@Test public void isValid_validParameterName_true() { assertTrue(objectUnderTests.isValid(Collections.singletonMap("test", null), null)); }
@Test public void isValid_parameterNameContainsUnderline_true() { assertTrue(objectUnderTests.isValid(Collections.singletonMap("test_test", null), null)); }
@Test public void isValid_paramNameStartWithNumber_false() { assertFalse(objectUnderTests.isValid(Collections.singletonMap("1test", null), null)); }
@Test public void isValid_parameterNameContainsSpecialSymbol_false() { assertFalse(objectUnderTests.isValid(Collections.singletonMap("test+test", null), null)); }
@Test public void isValid_parameterNameContainsSpace_false() { assertFalse(objectUnderTests.isValid(Collections.singletonMap("test test", null), null)); }
@Test public void isValid_nameStartWithSpace_false() { assertFalse(objectUnderTests.isValid(Collections.singletonMap("test ", null), null)); }
@Test public void isValid_nameEndsWithSpace_false() { assertFalse(objectUnderTests.isValid(Collections.singletonMap(" test", null), null)); }