@Test public void testFindItemDefinitionParentWhenParentDoesNotHaveTypeRef() { final DataType dataType = mock(DataType.class); final ItemDefinition parent = makeItemDefinition(); final String parentUUID = "parentUUID"; when(parent.getTypeRef()).thenReturn(null); when(dataType.getParentUUID()).thenReturn(parentUUID); when(itemDefinitionStore.get(parentUUID)).thenReturn(parent); final Optional<ItemDefinition> expectedParent = Optional.of(parent); final Optional<ItemDefinition> actualParent = handler.findItemDefinitionParent(dataType); assertEquals(expectedParent, actualParent); }
Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject  ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore,
                                        final DMNGraphUtils dmnGraphUtils,
                                        final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject  ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore,
                                        final DMNGraphUtils dmnGraphUtils,
                                        final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject  ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore,
                                        final DMNGraphUtils dmnGraphUtils,
                                        final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel);  }