@Test public void testWithSubDataTypes() { final DataType topLevelDataType = mock(DataType.class); final DataType subLevelDataType = mock(DataType.class); final String subLevelDataTypeUuid = "subUuid"; when(subLevelDataType.getUUID()).thenReturn(subLevelDataTypeUuid); final List<DataType> newSubDataTypes = singletonList(mock(DataType.class)); when(topLevelDataType.getSubDataTypes()).thenReturn(singletonList(subLevelDataType)); when(itemDefinitionUtils.findByName(anyString())).thenReturn(Optional.empty()); manager.withDataType(topLevelDataType); manager.withSubDataTypes(newSubDataTypes); verify(dataTypeStore).unIndex(subLevelDataTypeUuid); verify(itemDefinitionStore).unIndex(subLevelDataTypeUuid); verify(topLevelDataType).setSubDataTypes(newSubDataTypes); }
public DataTypeManager withSubDataTypes(final List<DataType> dataTypes) { if (!isReadOnly(dataType)) { dataType.getSubDataTypes().forEach(dataType -> { dataTypeStore.unIndex(dataType.getUUID()); itemDefinitionStore.unIndex(dataType.getUUID()); }); dataType.setSubDataTypes(dataTypes); } return this; }
DataTypeManager { public DataTypeManager withSubDataTypes(final List<DataType> dataTypes) { if (!isReadOnly(dataType)) { dataType.getSubDataTypes().forEach(dataType -> { dataTypeStore.unIndex(dataType.getUUID()); itemDefinitionStore.unIndex(dataType.getUUID()); }); dataType.setSubDataTypes(dataTypes); } return this; } }
DataTypeManager { public DataTypeManager withSubDataTypes(final List<DataType> dataTypes) { if (!isReadOnly(dataType)) { dataType.getSubDataTypes().forEach(dataType -> { dataTypeStore.unIndex(dataType.getUUID()); itemDefinitionStore.unIndex(dataType.getUUID()); }); dataType.setSubDataTypes(dataTypes); } return this; } @Inject  DataTypeManager(final TranslationService translationService,
                           final ItemDefinitionRecordEngine recordEngine,
                           final ItemDefinitionStore itemDefinitionStore,
                           final DataTypeStore dataTypeStore,
                           final ItemDefinitionUtils itemDefinitionUtils,
                           final ManagedInstance<DataTypeManager> dataTypeManagers,
                           final DataTypeNameValidator dataTypeNameValidator,
                           final DataTypeManagerStackStore typeStack); }
DataTypeManager { public DataTypeManager withSubDataTypes(final List<DataType> dataTypes) { if (!isReadOnly(dataType)) { dataType.getSubDataTypes().forEach(dataType -> { dataTypeStore.unIndex(dataType.getUUID()); itemDefinitionStore.unIndex(dataType.getUUID()); }); dataType.setSubDataTypes(dataTypes); } return this; } @Inject  DataTypeManager(final TranslationService translationService,
                           final ItemDefinitionRecordEngine recordEngine,
                           final ItemDefinitionStore itemDefinitionStore,
                           final DataTypeStore dataTypeStore,
                           final ItemDefinitionUtils itemDefinitionUtils,
                           final ManagedInstance<DataTypeManager> dataTypeManagers,
                           final DataTypeNameValidator dataTypeNameValidator,
                           final DataTypeManagerStackStore typeStack); DataTypeManager fromNew(); DataTypeManager from(final ItemDefinition itemDefinition); DataTypeManager from(final BuiltInType builtInType); DataTypeManager from(final DataType dataType); DataTypeManager withParentUUID(final String parentUUID); DataTypeManager withName(final String name); DataTypeManager withType(final String type); DataTypeManager withConstraint(final String constraint); DataTypeManager withConstraintType(final String constraintType); DataTypeManager asList(final boolean isCollection); DataTypeManager withNoConstraint(); DataTypeManager withDataType(final DataType dataType); DataTypeManager withItemDefinition(final ItemDefinition itemDefinition); DataTypeManager withRefreshedSubDataTypes(final String newType); DataTypeManager withSubDataTypes(final List<DataType> dataTypes); DataTypeManager withNoName(); DataTypeManager withUniqueName(); DataTypeManager withUniqueName(final String name); DataTypeManager withItemDefinitionSubDataTypes(); DataTypeManager withIndexedItemDefinition(); DataType get(); List<DataType> makeExternalDataTypes(final String typeName); String structure(); String getTypeName(); DataTypeManager asStructure(); Optional<DataType> getTopLevelDataTypeWithName(final String typeName); }
DataTypeManager { public DataTypeManager withSubDataTypes(final List<DataType> dataTypes) { if (!isReadOnly(dataType)) { dataType.getSubDataTypes().forEach(dataType -> { dataTypeStore.unIndex(dataType.getUUID()); itemDefinitionStore.unIndex(dataType.getUUID()); }); dataType.setSubDataTypes(dataTypes); } return this; } @Inject  DataTypeManager(final TranslationService translationService,
                           final ItemDefinitionRecordEngine recordEngine,
                           final ItemDefinitionStore itemDefinitionStore,
                           final DataTypeStore dataTypeStore,
                           final ItemDefinitionUtils itemDefinitionUtils,
                           final ManagedInstance<DataTypeManager> dataTypeManagers,
                           final DataTypeNameValidator dataTypeNameValidator,
                           final DataTypeManagerStackStore typeStack); DataTypeManager fromNew(); DataTypeManager from(final ItemDefinition itemDefinition); DataTypeManager from(final BuiltInType builtInType); DataTypeManager from(final DataType dataType); DataTypeManager withParentUUID(final String parentUUID); DataTypeManager withName(final String name); DataTypeManager withType(final String type); DataTypeManager withConstraint(final String constraint); DataTypeManager withConstraintType(final String constraintType); DataTypeManager asList(final boolean isCollection); DataTypeManager withNoConstraint(); DataTypeManager withDataType(final DataType dataType); DataTypeManager withItemDefinition(final ItemDefinition itemDefinition); DataTypeManager withRefreshedSubDataTypes(final String newType); DataTypeManager withSubDataTypes(final List<DataType> dataTypes); DataTypeManager withNoName(); DataTypeManager withUniqueName(); DataTypeManager withUniqueName(final String name); DataTypeManager withItemDefinitionSubDataTypes(); DataTypeManager withIndexedItemDefinition(); DataType get(); List<DataType> makeExternalDataTypes(final String typeName); String structure(); String getTypeName(); DataTypeManager asStructure(); Optional<DataType> getTopLevelDataTypeWithName(final String typeName);  }