@Test public void testDestroyWithoutDependentTypes() { final DataType dataType = mock(DataType.class); final List<DataType> dependentDataTypes = asList(mock(DataType.class), mock(DataType.class)); when(dataTypeDestroyHandler.refreshDependentDataTypes(dataType)).thenReturn(dependentDataTypes); final List<DataType> actualDependentDataTypes = recordEngine.destroyWithoutDependentTypes(dataType); final List<DataType> expectedDependentDataTypes = singletonList(dataType); verify(dataTypeDestroyHandler).destroy(dataType); verify(itemDefinitionDestroyHandler).destroy(dataType, false); assertEquals(expectedDependentDataTypes, actualDependentDataTypes); }
@Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; } @Inject  ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore,
                                      final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler,
                                      final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler,
                                      final ItemDefinitionCreateHandler itemDefinitionCreateHandler,
                                      final DataTypeDestroyHandler dataTypeDestroyHandler,
                                      final DataTypeUpdateHandler dataTypeUpdateHandler,
                                      final DataTypeCreateHandler dataTypeCreateHandler,
                                      final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; } @Inject  ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore,
                                      final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler,
                                      final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler,
                                      final ItemDefinitionCreateHandler itemDefinitionCreateHandler,
                                      final DataTypeDestroyHandler dataTypeDestroyHandler,
                                      final DataTypeUpdateHandler dataTypeUpdateHandler,
                                      final DataTypeCreateHandler dataTypeCreateHandler,
                                      final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record,
                                 final DataType reference,
                                 final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType,
                         final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; } @Inject  ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore,
                                      final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler,
                                      final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler,
                                      final ItemDefinitionCreateHandler itemDefinitionCreateHandler,
                                      final DataTypeDestroyHandler dataTypeDestroyHandler,
                                      final DataTypeUpdateHandler dataTypeUpdateHandler,
                                      final DataTypeCreateHandler dataTypeCreateHandler,
                                      final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record,
                                 final DataType reference,
                                 final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType,
                         final ItemDefinition itemDefinition); void doDestroy(final DataType dataType);  }