### Question:
DataTypeConfirmation { public void ifIsNotReferencedDataType(final DataType dataType, final Command onSuccess) { if (isReferencedByAnotherDataType(dataType)) { flashMessageEvent.fire(referencedDataTypeWarningMessage.getFlashMessage(dataType, onSuccess, () -> { })); } else { onSuccess.execute(); } } @Inject  DataTypeConfirmation(final DataTypeStore dataTypeStore,
                                final ItemDefinitionStore itemDefinitionStore,
                                final Event<FlashMessage> flashMessageEvent,
                                final DataTypeHasFieldsWarningMessage dataTypeHasFieldsWarningMessage,
                                final ReferencedDataTypeWarningMessage referencedDataTypeWarningMessage,
                                final TranslationService translationService); void ifDataTypeDoesNotHaveLostSubDataTypes(final DataType dataType,
                                                      final Command onSuccess,
                                                      final Command onError); void ifIsNotReferencedDataType(final DataType dataType,
                                          final Command onSuccess);  }### Answer:
@Test public void testIfIsNotReferencedDataTypeWhenCallbackIsExecuted() { final DataType dataType = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final List<DataType> allDataTypes = asList(dataType1, dataType2); final Command callback = mock(Command.class); final String tCity = "tCity"; final String tPerson = "tPerson"; final String tDocument = "tDocument"; when(dataType.getName()).thenReturn(tCity); when(dataType1.getType()).thenReturn(tDocument); when(dataType2.getType()).thenReturn(tPerson); when(dataTypeStore.all()).thenReturn(allDataTypes); confirmation.ifIsNotReferencedDataType(dataType, callback); verify(callback).execute(); }
@Test public void testIfIsNotReferencedDataTypeWhenCallbackIsNotExecuted() { final DataType dataType = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final List<DataType> allDataTypes = asList(dataType1, dataType2); final FlashMessage warningMessage = mock(FlashMessage.class); final Command onSuccess = mock(Command.class); final String tCity = "tCity"; final String tPerson = "tPerson"; when(dataType.getName()).thenReturn(tCity); when(dataType1.getType()).thenReturn(tCity); when(dataType2.getType()).thenReturn(tPerson); when(referencedDataTypeWarningMessage.getFlashMessage(eq(dataType), eq(onSuccess), any())).thenReturn(warningMessage); when(dataTypeStore.all()).thenReturn(allDataTypes); confirmation.ifIsNotReferencedDataType(dataType, onSuccess); verify(onSuccess, never()).execute(); verify(flashMessageEvent).fire(warningMessage); }