ConstraintServices { void extractViolationInfoFromNode(Path.Node node, ConstraintViolation cv) { ElementKind kind = node.getKind(); logger.debug("Kind:{} Index:{} Key:{} Name:{}", kind, node.getIndex(), node.getKey(), node.getName()); if (ElementKind.PARAMETER.equals(kind)) { cv.setIndex(getIndexFromArgname(node.getName())); } else if (ElementKind.PROPERTY.equals(kind)) { cv.setProp(node.getName()); } }  ConstraintViolation[] extractViolations(ConstraintViolationException cve);  }
@Test public void testExtractViolationInfoFromNode() { System.out.println("extractViolationInfoFromNode"); Path.Node node = mock(Path.Node.class); when(node.getKind()).thenReturn(ElementKind.METHOD).thenReturn(ElementKind.PARAMETER).thenReturn(ElementKind.PROPERTY); when(node.getName()).thenReturn("arg0").thenReturn("prop"); doReturn(5).when(instance).getIndexFromArgname(anyString()); ConstraintViolation cv = new ConstraintViolation(); instance.extractViolationInfoFromNode(node, cv); assertThat(cv.getMessage()).isNull(); assertThat(cv.getIndex()).isEqualTo(0); assertThat(cv.getProp()).isNull(); cv = new ConstraintViolation(); instance.extractViolationInfoFromNode(node, cv); assertThat(cv.getMessage()).isNull(); assertThat(cv.getIndex()).isEqualTo(5); assertThat(cv.getProp()).isNull(); cv = new ConstraintViolation(); instance.extractViolationInfoFromNode(node, cv); assertThat(cv.getMessage()).isNull(); assertThat(cv.getIndex()).isEqualTo(0); assertThat(cv.getProp()).isEqualTo("prop"); }