public static boolean validade(PropertyEditorEvent event) { if (event == null) { throw new NullEventException("Event should not be null,"); } if (event.getSortedProperties().isEmpty()) { throw new NoPropertiesException("Event should not have empty properties."); } return event != null && !event.getSortedProperties().isEmpty(); }
public static void extractEditorFrom(final PropertyEditorWidget propertyEditorWidget, final PanelGroup propertyMenu, final PropertyEditorEvent event, final String propertyNameFilter) { propertyMenu.clear(); for (PropertyEditorCategory category : event.getSortedProperties()) { createCategory(propertyEditorWidget, propertyMenu, category, propertyNameFilter); } }
@Test public void sortCategoryByPriority() { List<PropertyEditorCategory> categories = new ArrayList<PropertyEditorCategory>(); PropertyEditorCategory category1 = new PropertyEditorCategory("cat1", 2); categories.add(category1); PropertyEditorCategory category2 = new PropertyEditorCategory("catHighPriority", 1); categories.add(category2); PropertyEditorEvent event = new PropertyEditorEvent("event", categories); assertEquals(category2, event.getSortedProperties().get(0)); assertEquals(category1, event.getSortedProperties().get(1)); }
@Test public void sortCategoryByPriority() { List<PropertyEditorCategory> categories = new ArrayList<PropertyEditorCategory>(); PropertyEditorCategory category1 = new PropertyEditorCategory("cat1", 2); categories.add(category1); PropertyEditorCategory category2 = new PropertyEditorCategory("catHighPriority", 1); categories.add(category2); PropertyEditorEvent event = new PropertyEditorEvent("event", categories); assertEquals(category2, event.getSortedProperties().get(0)); assertEquals(category1, event.getSortedProperties().get(1)); }
@Test public void sortFieldsByPriority() { PropertyEditorFieldInfo highPriority = new PropertyEditorFieldInfo("highPriority", PropertyEditorType.BOOLEAN).withPriority(1); PropertyEditorFieldInfo lowPriority = new PropertyEditorFieldInfo("lowPriority", PropertyEditorType.BOOLEAN).withPriority(10); PropertyEditorCategory category = new PropertyEditorCategory("cat1", 2) .withField(lowPriority) .withField(highPriority); PropertyEditorEvent event = new PropertyEditorEvent("event", category); assertEquals(highPriority, event.getSortedProperties().get(0).getFields().get(0)); assertEquals(lowPriority, event.getSortedProperties().get(0).getFields().get(1)); } }
@Test public void sortFieldsByPriority() { PropertyEditorFieldInfo highPriority = new PropertyEditorFieldInfo("highPriority", PropertyEditorType.BOOLEAN).withPriority(1); PropertyEditorFieldInfo lowPriority = new PropertyEditorFieldInfo("lowPriority", PropertyEditorType.BOOLEAN).withPriority(10); PropertyEditorCategory category = new PropertyEditorCategory("cat1", 2) .withField(lowPriority) .withField(highPriority); PropertyEditorEvent event = new PropertyEditorEvent("event", category); assertEquals(highPriority, event.getSortedProperties().get(0).getFields().get(0)); assertEquals(lowPriority, event.getSortedProperties().get(0).getFields().get(1)); } }