/** * {@inheritDoc} */ @Override public void deleteAlertingDefinition(AlertingDefinition alertingDefinition) throws BusinessException { try { ciManager.deleteAlertingDefinition(alertingDefinition); } catch (IOException e) { throw new TechnicalException("Delete the alerting definition '" + alertingDefinition.getName() + "'.", ConfigurationInterfaceErrorCodeEnum.INPUT_OUTPUT_OPERATION_FAILED, e); } }
@Test(expectedExceptions = { TechnicalException.class }) public void ioExceptionThrown() throws BusinessException, JAXBException, IOException { doThrow(IOException.class).when(ciManager).deleteAlertingDefinition(firstAlertingDefinition); ciService.deleteAlertingDefinition(firstAlertingDefinition); } }
@Test public void deleteAlertingDefinitionNotExisting() throws Exception { AlertingDefinition alertingDefinition = new AlertingDefinition(); alertingDefinition.setId("not-existing"); manager.deleteAlertingDefinition(alertingDefinition); verify(eventPublisher, never()).publishEvent(any(ApplicationEvent.class)); } }
@Test public void deleteAlertingDefinition() throws Exception { AlertingDefinition alertingDefinition = new AlertingDefinition(); alertingDefinition.setName("test"); manager.createAlertingDefinition(alertingDefinition); manager.deleteAlertingDefinition(alertingDefinition); assertThat(manager.getAlertingDefinitions(), not(hasItem(alertingDefinition))); ArgumentCaptor<ApplicationEvent> captor = ArgumentCaptor.forClass(ApplicationEvent.class); verify(eventPublisher, times(2)).publishEvent(captor.capture()); assertThat(captor.getAllValues().get(0), is(instanceOf(AbstractAlertingDefinitionEvent.AlertingDefinitionCreatedEvent.class))); assertThat(captor.getAllValues().get(1), is(instanceOf(AbstractAlertingDefinitionEvent.AlertingDefinitionDeletedEvent.class))); }
@Test public void deleteAlertingDefinition() throws BusinessException, JAXBException, IOException { ciService.deleteAlertingDefinition(firstAlertingDefinition); verify(ciManager, only()).deleteAlertingDefinition(firstAlertingDefinition); }