AttributeSet { public void validate(AssignationLevel assignationLevel) { for (Attribute attr : attributeMap.values()) { if (!attr.canBeAssignedTo(assignationLevel)) { throw new IllegalArgumentException(String.format("Attribute '%s' cannot be assigned to level %s", attr.getCoRELinkParam(), assignationLevel.name())); } } Attribute pmin = attributeMap.get(Attribute.MINIMUM_PERIOD); Attribute pmax = attributeMap.get(Attribute.MAXIMUM_PERIOD); if ((pmin != null) && (pmax != null) && (Long) pmin.getValue() > (Long) pmax.getValue()) { throw new IllegalArgumentException(String.format("Cannot write attributes where '%s' > '%s'", pmin.getCoRELinkParam(), pmax.getCoRELinkParam())); } } AttributeSet(Attribute... attributes);  AttributeSet(Collection<Attribute> attributes); void validate(AssignationLevel assignationLevel); AttributeSet filter(Attachment attachment); AttributeSet merge(AttributeSet attributes); Map<String, Object> getMap(); Collection<Attribute> getAttributes(); String[] toQueryParams(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static AttributeSet parse(String uriQueries); static AttributeSet parse(String... queryParams); static AttributeSet parse(Collection<String> queryParams);  }
@Test(expected = IllegalArgumentException.class) public void should_throw_on_invalid_assignation_level() { AttributeSet sut = new AttributeSet(new Attribute(Attribute.OBJECT_VERSION, "1.1"), new Attribute(Attribute.MINIMUM_PERIOD, 5L), new Attribute(Attribute.MAXIMUM_PERIOD, 60L)); sut.validate(AssignationLevel.RESOURCE); }
@Test(expected = IllegalArgumentException.class) public void should_throw_on_invalid_pmin_pmax() { AttributeSet sut = new AttributeSet(new Attribute(Attribute.MINIMUM_PERIOD, 50L), new Attribute(Attribute.MAXIMUM_PERIOD, 49L)); sut.validate(AssignationLevel.RESOURCE); }