### Question:
ConsistentReferenceNameValidator implements ConstraintValidator<ConsistentReferenceName, ReferenceElement>,
        ValidationErrorDescriptorBuilder { @Override public ErrorDescriptor build(ConstraintViolation violation) { final ReferenceElement invalidValue = (ReferenceElement) violation.getInvalidValue(); String expectedName = getReferencedResourceName(invalidValue.getReferencePath()); return new ErrorDescriptor().setErrorCode("domain.schema.resources.join.reference.name.inconsistent") .setMessage("Reference name should be the same as name of referenced resource. I.e. \"" + expectedName + "\"").addProperties( new ClientProperty("expectedName", expectedName), new ClientProperty("currentName", invalidValue.getName()) ); }  @Override ErrorDescriptor build(ConstraintViolation violation); @Override void initialize(ConsistentReferenceName constraintAnnotation); @Override boolean isValid(ReferenceElement value, ConstraintValidatorContext context);  }### Answer:
@Test public void build_withValidationContext_withResourcePathProperty(){ final ConstraintViolation constraintViolation = mock(ConstraintViolation.class); final Path path = mock(Path.class); when(constraintViolation.getPropertyPath()).thenReturn(path); final String expectedJsonPath = "schema.resources[1].elements[2]"; when(path.toString()).thenReturn(expectedJsonPath); final ClientDomain clientDomain = new ClientDomain().setSchema( new Schema().setResources((List) Arrays.asList( new ResourceGroupElement(), new JoinResourceGroupElement().setName("joinGroupName") .setElements((List) Arrays.asList( new ReferenceElement(), new ReferenceElement(), new ReferenceElement().setName("referenceElementName") )))) ); when(constraintViolation.getRootBean()).thenReturn(clientDomain); when(constraintViolation.getInvalidValue()) .thenReturn(new ReferenceElement().setName("someName").setReferencePath("name1.name2")); final ErrorDescriptor result = validator.build(constraintViolation); final ErrorDescriptor expectedErrorDescriptor = new ErrorDescriptor() .setErrorCode("domain.schema.resources.join.reference.name.inconsistent") .addProperties( new ClientProperty("expectedName", "name2"), new ClientProperty("currentName", "someName") ); assertTrue(new MessageAgnosticErrorDescriptor(expectedErrorDescriptor) .equals(new MessageAgnosticErrorDescriptor(result))); }