@Test public void testDestroy() { final ItemDefinition item1 = makeItemDefinition("model1.tPerson", null, true); final ItemDefinition item2 = makeItemDefinition("model1.id", "number", true); final ItemDefinition item3 = makeItemDefinition("model1.name", "string", true); final ItemDefinition item4 = makeItemDefinition("person", "model1.tPerson", false); final ItemDefinition item5 = makeItemDefinition("tUUID", "string", false); final List<ItemDefinition> itemDefinitions = new ArrayList<>(asList(item1, item2, item3, item4, item5)); when(itemDefinitionUtils.all()).thenReturn(itemDefinitions); handler.destroy("model1"); verify(refreshDataTypesListEvent).fire(any(RefreshDataTypesListEvent.class)); assertEquals(1, itemDefinitions.size()); assertEquals("tUUID", itemDefinitions.get(0).getName().getValue()); assertEquals("string", itemDefinitions.get(0).getTypeRef().getLocalPart()); }
@Override public void destroy(final String oldModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); itemDefinitionUtils.all().removeIf(itemDefinition -> { return updatedItemDefinitionsByName.contains(itemDefinition) || updatedItemDefinitionsByType.contains(itemDefinition); }); refreshDataTypesList(); }
ItemDefinitionHandler implements DRGElementHandler { @Override public void destroy(final String oldModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); itemDefinitionUtils.all().removeIf(itemDefinition -> { return updatedItemDefinitionsByName.contains(itemDefinition) || updatedItemDefinitionsByType.contains(itemDefinition); }); refreshDataTypesList(); } }
ItemDefinitionHandler implements DRGElementHandler { @Override public void destroy(final String oldModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); itemDefinitionUtils.all().removeIf(itemDefinition -> { return updatedItemDefinitionsByName.contains(itemDefinition) || updatedItemDefinitionsByType.contains(itemDefinition); }); refreshDataTypesList(); } @Inject  ItemDefinitionHandler(final ItemDefinitionUtils itemDefinitionUtils,
                                 final Event<RefreshDataTypesListEvent> refreshDataTypesListEvent,
                                 final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionHandler implements DRGElementHandler { @Override public void destroy(final String oldModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); itemDefinitionUtils.all().removeIf(itemDefinition -> { return updatedItemDefinitionsByName.contains(itemDefinition) || updatedItemDefinitionsByType.contains(itemDefinition); }); refreshDataTypesList(); } @Inject  ItemDefinitionHandler(final ItemDefinitionUtils itemDefinitionUtils,
                                 final Event<RefreshDataTypesListEvent> refreshDataTypesListEvent,
                                 final PropertiesPanelNotifier panelNotifier); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName); }
ItemDefinitionHandler implements DRGElementHandler { @Override public void destroy(final String oldModelName) { final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName); final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName); itemDefinitionUtils.all().removeIf(itemDefinition -> { return updatedItemDefinitionsByName.contains(itemDefinition) || updatedItemDefinitionsByType.contains(itemDefinition); }); refreshDataTypesList(); } @Inject  ItemDefinitionHandler(final ItemDefinitionUtils itemDefinitionUtils,
                                 final Event<RefreshDataTypesListEvent> refreshDataTypesListEvent,
                                 final PropertiesPanelNotifier panelNotifier); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName);  }