@Test public void testUpdate() { final String uuid = "uuid"; final String nameValue = "nameValue"; final DataType dataType = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); final Name name = mock(Name.class); final List<DataType> expectedDependentDataTypes = asList(mock(DataType.class), mock(DataType.class)); when(dataType.isValid()).thenReturn(true); when(dataType.getUUID()).thenReturn(uuid); when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition); when(itemDefinition.getName()).thenReturn(name); when(name.getValue()).thenReturn(nameValue); when(dataTypeUpdateHandler.refreshDependentDataTypes(dataType, nameValue)).thenReturn(expectedDependentDataTypes); final List<DataType> actualDependentDataTypes = recordEngine.update(dataType); verify(recordEngine).doUpdate(dataType, itemDefinition); assertEquals(expectedDependentDataTypes, actualDependentDataTypes); }
@Override public List<DataType> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); } @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> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); } @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> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); } @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);  }