@Test public void testLookupAbsoluteParentWhenReferenceTypeIsNotStructure() { final DataType reference = mock(DataType.class); final DataType expectedParent = mock(DataType.class); final DataType tCityTopLevel = mock(DataType.class); final String parentUUID = "parentUUID"; final String structure = "Structure"; final String type = "tCity"; when(reference.getParentUUID()).thenReturn(parentUUID); when(expectedParent.getType()).thenReturn(type); when(tCityTopLevel.getName()).thenReturn(type); when(dataTypeStore.get(parentUUID)).thenReturn(expectedParent); when(dataTypeManager.structure()).thenReturn(structure); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(singletonList(tCityTopLevel)); final Optional<DataType> actualParent = handler.lookupAbsoluteParent(reference); assertEquals(Optional.of(tCityTopLevel), actualParent); }
Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject  DataTypeCreateHandler(final DataTypeStore dataTypeStore,
                                 final DataTypeManager dataTypeManager); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject  DataTypeCreateHandler(final DataTypeStore dataTypeStore,
                                 final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType,
                                 final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType,
                                        final DataType reference,
                                        final CreationType creationType,
                                        final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType,
                                       final DataType reference,
                                       final ItemDefinition itemDefinition); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject  DataTypeCreateHandler(final DataTypeStore dataTypeStore,
                                 final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType,
                                 final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType,
                                        final DataType reference,
                                        final CreationType creationType,
                                        final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType,
                                       final DataType reference,
                                       final ItemDefinition itemDefinition);  }