@Test public void validate() { when(propertyValidation1.hasErrors()).thenReturn(true); when(property1.validate()).thenReturn(propertyValidation1); when(propertyValidation2.hasErrors()).thenReturn(false); when(property2.validate()).thenReturn(propertyValidation2); Map<AbstractProperty, PropertyValidation> validateMap = configuration.validate(); assertThat(validateMap, hasEntry(property1, propertyValidation1)); assertThat(validateMap, not(hasKey(property2))); }
public Map<AbstractProperty, PropertyValidation> validate() { Map<AbstractProperty, PropertyValidation> validationMap = new HashMap<>(); for (AbstractProperty property : getAllProperties()) { PropertyValidation propertyValidation = property.validate(); if (propertyValidation.hasErrors()) { validationMap.put(property, propertyValidation); } } return validationMap; }
Configuration { public Map<AbstractProperty, PropertyValidation> validate() { Map<AbstractProperty, PropertyValidation> validationMap = new HashMap<>(); for (AbstractProperty property : getAllProperties()) { PropertyValidation propertyValidation = property.validate(); if (propertyValidation.hasErrors()) { validationMap.put(property, propertyValidation); } } return validationMap; } }
Configuration { public Map<AbstractProperty, PropertyValidation> validate() { Map<AbstractProperty, PropertyValidation> validationMap = new HashMap<>(); for (AbstractProperty property : getAllProperties()) { PropertyValidation propertyValidation = property.validate(); if (propertyValidation.hasErrors()) { validationMap.put(property, propertyValidation); } } return validationMap; }  }
Configuration { public Map<AbstractProperty, PropertyValidation> validate() { Map<AbstractProperty, PropertyValidation> validationMap = new HashMap<>(); for (AbstractProperty property : getAllProperties()) { PropertyValidation propertyValidation = property.validate(); if (propertyValidation.hasErrors()) { validationMap.put(property, propertyValidation); } } return validationMap; }  Map<AbstractProperty, PropertyValidation> validate(); @SuppressWarnings("unchecked") SingleProperty<T> forLogicalName(String propertyLogicalName); Collection<AbstractProperty> getAllProperties(); void addSection(PropertySection section); Set<PropertySection> getSections(); void setSections(Set<PropertySection> sections); @Override int hashCode(); @Override boolean equals(Object obj); }
Configuration { public Map<AbstractProperty, PropertyValidation> validate() { Map<AbstractProperty, PropertyValidation> validationMap = new HashMap<>(); for (AbstractProperty property : getAllProperties()) { PropertyValidation propertyValidation = property.validate(); if (propertyValidation.hasErrors()) { validationMap.put(property, propertyValidation); } } return validationMap; }  Map<AbstractProperty, PropertyValidation> validate(); @SuppressWarnings("unchecked") SingleProperty<T> forLogicalName(String propertyLogicalName); Collection<AbstractProperty> getAllProperties(); void addSection(PropertySection section); Set<PropertySection> getSections(); void setSections(Set<PropertySection> sections); @Override int hashCode(); @Override boolean equals(Object obj);  }