/** * {@inheritDoc} */ @Override public ApplicationDefinition addApplicationDefinition(ApplicationDefinition appDefinition) throws BusinessException { return addApplicationDefinition(appDefinition, -1); }
@Test(expectedExceptions = { BusinessException.class }) public void addDuplicate() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(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 deleteDefaultApplication() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.deleteApplicationDefinition(ApplicationDefinition.DEFAULT_APPLICATION_DEFINITION); assertThat(ciService.getApplicationDefinitions(), hasSize(3)); }
@SuppressWarnings("unchecked") @Test(expectedExceptions = { TechnicalException.class }) public void ioExceptionThrown() throws BusinessException, JAXBException, IOException { when(ciManager.updateBusinessContextDefinition(any(BusinessContextDefinition.class))).thenThrow(IOException.class); ciService.addApplicationDefinition(firstAppDefinition); } }
@Test public void getApplicationDefitions() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); assertThat(ciService.getApplicationDefinitions(), hasItem(firstAppDefinition)); assertThat(ciService.getApplicationDefinitions(), hasItem(secondAppDefinition)); }
@Test(expectedExceptions = { BusinessException.class }) public void updateUnknown() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.updateApplicationDefinition(new ApplicationDefinition(123456789, "unknown", null)); }
@Test(expectedExceptions = { BusinessException.class }) public void moveUnknown() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.moveApplicationDefinition(new ApplicationDefinition(123456789, "unknown", null), 0); }
@SuppressWarnings("unchecked") @Test(expectedExceptions = { TechnicalException.class }) public void jaxbExceptionThrown() throws BusinessException, JAXBException, IOException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); when(ciManager.updateBusinessContextDefinition(any(BusinessContextDefinition.class))).thenThrow(JAXBException.class); ciService.moveApplicationDefinition(secondAppDefinition, 0); }
@Test public void deleteNull() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.deleteApplicationDefinition(null); assertThat(ciService.getApplicationDefinitions(), hasSize(3)); }
@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 public void moveApplicationDefinitionUp() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.moveApplicationDefinition(secondAppDefinition, 0); assertThat(ciService.getApplicationDefinitions().get(0), is(secondAppDefinition)); assertThat(ciService.getApplicationDefinitions().get(1), is(firstAppDefinition)); }
@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 public void moveToSameIndex() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.moveApplicationDefinition(secondAppDefinition, 1); assertThat(ciService.getApplicationDefinitions().get(0), is(firstAppDefinition)); assertThat(ciService.getApplicationDefinitions().get(1), is(secondAppDefinition)); }
@Test public void deleteUnknown() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.deleteApplicationDefinition(new ApplicationDefinition(123456789, "unknown", null)); assertThat(ciService.getApplicationDefinitions(), hasSize(3)); }
@Test public void deleteTwice() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.deleteApplicationDefinition(firstAppDefinition); ciService.deleteApplicationDefinition(firstAppDefinition); assertThat(ciService.getApplicationDefinitions(), hasSize(2)); }
@SuppressWarnings("unchecked") @Test(expectedExceptions = { TechnicalException.class }) public void jaxbExceptionThrown() throws BusinessException, JAXBException, IOException { ciService.addApplicationDefinition(firstAppDefinition); when(ciManager.updateBusinessContextDefinition(any(BusinessContextDefinition.class))).thenThrow(JAXBException.class); ciService.updateApplicationDefinition(firstAppDefinition); }
@Test public void deleteApplicationDefition() throws BusinessException { ciService.addApplicationDefinition(firstAppDefinition); ciService.addApplicationDefinition(secondAppDefinition); ciService.deleteApplicationDefinition(secondAppDefinition); assertThat(ciService.getApplicationDefinitions(), hasSize(2)); assertThat(ciService.getApplicationDefinitions().get(0), is(firstAppDefinition)); assertThat(ciService.getApplicationDefinitions().get(1), equalTo(ApplicationDefinition.DEFAULT_APPLICATION_DEFINITION)); ciService.deleteApplicationDefinition(firstAppDefinition); assertThat(ciService.getApplicationDefinitions(), hasSize(1)); assertThat(ciService.getApplicationDefinitions().get(0), equalTo(ApplicationDefinition.DEFAULT_APPLICATION_DEFINITION)); }
@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")); }