@Test public void testNonStringMapKey() { Validator validator = ValidatorUtil.getValidator(); Container container = new Container(); Key id = new Key(); container.addItem(id, new Item(null)); Set<ConstraintViolation<Container>> constraintViolations = validator.validate(container); assertNumberOfViolations(constraintViolations, 1); ConstraintViolation<Container> violation = constraintViolations.iterator().next(); Path path = violation.getPropertyPath(); Iterator<Path.Node> iter = path.iterator(); iter.next(); Path.Node node = iter.next(); assertNotNull(node); assertTrue(node.isInIterable()); assertEquals(node.getKey(), id); }
@Test public void testParseMapBasedProperty() { String property = "order[foo].deliveryAddress"; Path path = PathImpl.createPathFromString(property); Iterator<Path.Node> propIter = path.iterator(); assertTrue(propIter.hasNext()); Path.Node elem = propIter.next(); assertEquals("order", elem.getName()); assertFalse(elem.isInIterable()); assertTrue(propIter.hasNext()); elem = propIter.next(); assertEquals("deliveryAddress", elem.getName()); assertTrue(elem.isInIterable()); assertEquals("foo", elem.getKey()); assertFalse(propIter.hasNext()); }