@Test public void deleteTwice() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.deleteApplicationDefinition(firstAppDefinition); ciService.deleteApplicationDefinition(firstAppDefinition); assertThat(ciService.getApplicationDefinitions(), hasSize(2)); }
@Test public void getApplicationDefitionsForIds() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); assertThat(ciService.getApplicationDefinition(firstApplicationId), is(firstAppDefinition)); assertThat(ciService.getApplicationDefinition(secondApplicationId), is(secondAppDefinition)); assertThat(ciService.getApplicationDefinition(ApplicationDefinition.DEFAULT_ID), equalTo(ApplicationDefinition.DEFAULT_APPLICATION_DEFINITION)); } }
@Test public void moveApplicationDefinitionDown() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.moveApplicationDefinition(firstAppDefinition, 1); assertThat(ciService.getApplicationDefinitions().get(0), is(secondAppDefinition)); assertThat(ciService.getApplicationDefinitions().get(1), is(firstAppDefinition)); }
@Test(expectedExceptions = { BusinessException.class }) public void moveNull() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.moveApplicationDefinition(null, 0); }
@Test(expectedExceptions = { BusinessException.class }) public void updateNull() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.updateApplicationDefinition(null); }
@Test public void updateApplicationDefition() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); firstAppDefinition.setApplicationName("newName"); ciService.updateApplicationDefinition(firstAppDefinition); assertThat(ciService.getApplicationDefinition(firstApplicationId).getApplicationName(), equalTo("newName")); assertThat(ciService.getApplicationDefinition(secondApplicationId).getApplicationName(), equalTo("secondAppDefinition")); }
@Test public void getApplicationDefitions() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); assertThat(ciService.getApplicationDefinitions(), hasItem(firstAppDefinition)); assertThat(ciService.getApplicationDefinitions(), hasItem(secondAppDefinition)); }
/** * {@inheritDoc} */ @Override public ApplicationDefinition addApplicationDefinition(ApplicationDefinition appDefinition) throws BusinessException { return addApplicationDefinition(appDefinition, -1); }
@Test(expectedExceptions = { TechnicalException.class }) public void ioExceptionThrown() throws BusinessException, JAXBException, IOException { doThrow(IOException.class).when(ciManager).updateAlertingDefinition(firstAlertingDefinition); ciService.updateAlertingDefinition(firstAlertingDefinition); } }
@Test public void createAlertingDefinition() throws BusinessException, JAXBException, IOException { when(ciManager.createAlertingDefinition(firstAlertingDefinition)).thenReturn(firstAlertingDefinition); AlertingDefinition returnedDefinition = ciService.createAlertingDefinition(firstAlertingDefinition); assertThat(returnedDefinition, is(firstAlertingDefinition)); }
@SuppressWarnings("unchecked") @Test(expectedExceptions = { TechnicalException.class }) public void jaxbExceptionThrown() throws BusinessException, JAXBException, IOException { when(ciManager.updateBusinessContextDefinition(any(BusinessContextDefinition.class))).thenThrow(JAXBException.class); ciService.deleteApplicationDefinition(firstAppDefinition); }
@Test(expectedExceptions = { TechnicalException.class }) public void ioExceptionThrown() throws BusinessException, JAXBException, IOException { doThrow(IOException.class).when(ciManager).deleteAlertingDefinition(firstAlertingDefinition); ciService.deleteAlertingDefinition(firstAlertingDefinition); } }
applicationDefinition.addBusinessTransactionDefinition(businessTxDefinition_1); when(ciService.getApplicationDefinitions()).thenReturn(Collections.singletonList(applicationDefinition));
@Test public void getAlertingDefinitions() throws BusinessException, JAXBException, IOException { List<AlertingDefinition> definitions = Arrays.asList(firstAlertingDefinition, secondAlertingDefinition); when(ciManager.getAlertingDefinitions()).thenReturn(definitions); List<AlertingDefinition> alertingDefinitions = ciService.getAlertingDefinitions(); assertThat(alertingDefinitions, is(definitions)); }
@Test public void getAlertingDefinition() throws BusinessException, JAXBException, IOException { when(ciManager.getAlertingDefinition(secondAlertingDefinitionId)).thenReturn(secondAlertingDefinition); AlertingDefinition alertingDefinition = ciService.getAlertingDefinition(secondAlertingDefinitionId); assertThat(alertingDefinition, is(secondAlertingDefinition)); } }
@Test(expectedExceptions = { BusinessException.class }) public void moveToFar() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.moveApplicationDefinition(secondAppDefinition, 2); }
@Test(expectedExceptions = { BusinessException.class }) public void updateUnknown() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.updateApplicationDefinition(new ApplicationDefinition(123456789, "unknown", null)); }
@Test public void addAtPosition() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); assertThat(ciService.getApplicationDefinitions(), hasSize(2)); ciService.addApplicationDefinition(secondAppDefinition, 0); assertThat(ciService.getApplicationDefinitions(), hasSize(3)); assertThat(ciService.getApplicationDefinitions().get(0), is(secondAppDefinition)); }
@Test(expectedExceptions = { BusinessException.class }) public void addDuplicate() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(firstAppDefinition); }
@Test public void updateAlertingDefinition() throws BusinessException, JAXBException, IOException { when(ciManager.updateAlertingDefinition(firstAlertingDefinition)).thenReturn(firstAlertingDefinition); AlertingDefinition alertingDefinition = ciService.updateAlertingDefinition(firstAlertingDefinition); assertThat(alertingDefinition, is(firstAlertingDefinition)); }