@Test public void testExceptionMessageAndThrowableConstructor() throws Exception { Exception exception = new Exception(TEST_MESSAGE_2); ObjectNotFoundException ObjectNotFoundException = new ObjectNotFoundException(TEST_MESSAGE_1, exception); assertTrue(ObjectNotFoundException.getMessage().equals(TEST_MESSAGE_1)); assertTrue(ObjectNotFoundException.getCause().getMessage().equals(TEST_MESSAGE_2)); }
@Test public void testExceptionMessageConstructor() throws Exception { ObjectNotFoundException exception = new ObjectNotFoundException(TEST_MESSAGE_1); assertTrue(exception.getMessage().equals(TEST_MESSAGE_1)); }
@Test public void testExceptionNoArgConstructor() throws Exception { ObjectNotFoundException exception = new ObjectNotFoundException(); assertTrue(exception.getMessage() == null); }
@Test public void testGetTagsTagTypeNoExists() { // Try to retrieve a list of tag keys for a non-existing tag type. try { tagService.getTags(TAG_TYPE, NO_PARENT_TAG_CODE); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Tag type with code \"%s\" doesn't exist.", TAG_TYPE), e.getMessage()); } }
@Test public void testGetStorageUnitNotificationRegistrationsByNamespaceNamespaceNoExists() { // Try to retrieve storage unit notifications for a non-existing namespace. try { storageUnitNotificationRegistrationService.getStorageUnitNotificationRegistrationsByNamespace(NAMESPACE); fail("Should throw an ObjectNotFoundException when using non-existing namespace."); } catch (ObjectNotFoundException e) { assertEquals(String.format("Namespace \"%s\" doesn't exist.", NAMESPACE), e.getMessage()); } }
@Test public void testGetSecurityRoleThatDoesNotExist() { try { // Retrieve the security role that does not exist. securityRoleService.getSecurityRole(new SecurityRoleKey(SECURITY_ROLE)); fail("Should throw ObjectNotFoundException when security role does not exist"); } catch (ObjectNotFoundException e) { assertEquals(String.format("Security role with name \"%s\" doesn't exist.", SECURITY_ROLE), e.getMessage()); } }
@Test public void testGetNamespaceNoExists() throws Exception { // Try to get a non-existing namespace. try { namespaceService.getNamespace(new NamespaceKey(NAMESPACE)); fail("Should throw an ObjectNotFoundException when namespace doesn't exist."); } catch (ObjectNotFoundException e) { assertEquals(String.format("Namespace \"%s\" doesn't exist.", NAMESPACE), e.getMessage()); } }
@Test public void testGetDataProviderNoExists() throws Exception { // Try to get a non-existing data provider. try { dataProviderService.getDataProvider(new DataProviderKey(DATA_PROVIDER_NAME)); fail("Should throw an ObjectNotFoundException when data provider doesn't exist."); } catch (ObjectNotFoundException e) { assertEquals(String.format("Data provider with name \"%s\" doesn't exist.", DATA_PROVIDER_NAME), e.getMessage()); } }
@Test public void testDeleteStorageInvalidName() { // Try to delete a storage which doesn't exist. try { storageService.deleteStorage(new StorageKey(INVALID_VALUE)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage()); } }
@Test public void testGetTagTypeTagTypeNotExists() { // Try to retrieve a tag type instance when tag type code is not registered. try { tagTypeService.getTagType(new TagTypeKey(TAG_TYPE)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Tag type with code \"%s\" doesn't exist.", TAG_TYPE), e.getMessage()); } }
@Test public void testDeleteNonExistingSecurityRole() { // Try to delete a non-existing security role. try { securityRoleService.deleteSecurityRole(new SecurityRoleKey(SECURITY_ROLE)); fail("Should throw an ObjectNotFoundException when security role doesn't exist."); } catch (ObjectNotFoundException e) { assertEquals(String.format("Security role with name \"%s\" doesn't exist.", SECURITY_ROLE), e.getMessage()); } }
@Test public void testDeleteTagTypeTagTypeNotExists() { // Try to delete a tag type instance when tag type code is not specified. try { tagTypeService.deleteTagType(new TagTypeKey(I_DO_NOT_EXIST)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Tag type with code \"%s\" doesn't exist.", I_DO_NOT_EXIST), e.getMessage()); } }
@Test public void testGetBusinessObjectDefinitionTagsByTagTagNoExists() { // Try to get business object definition tags for a non-existing tag. try { businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByTag(new TagKey(TAG_TYPE, TAG_CODE)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Tag with code \"%s\" doesn't exist for tag type \"%s\".", TAG_CODE, TAG_TYPE), e.getMessage()); } }
@Test public void testDeleteTagTagNoExists() { // Try to delete a non-existing tag. try { tagService.deleteTag(new TagKey(TAG_TYPE, TAG_CODE)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Tag with code \"%s\" doesn't exist for tag type \"%s\".", TAG_CODE, TAG_TYPE), e.getMessage()); } }
@Test public void testGetTagTagNoExists() { // Try to get a non-existing tag. try { tagService.getTag(new TagKey(TAG_TYPE, TAG_CODE)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Tag with code \"%s\" doesn't exist for tag type \"%s\".", TAG_CODE, TAG_TYPE), e.getMessage()); } }
@Test public void testGetStorageInvalidStorageName() { // Try getting a storage that doesn't exist. try { storageService.getStorage(new StorageKey(INVALID_VALUE)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage()); } }
@Test public void testGetUserNamespaceAuthorizationsByNamespaceNamespaceNoExists() throws Exception { // Try to retrieve user namespace authorizations for a non-existing namespace. try { userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByNamespace("I_DO_NOT_EXIST"); fail("Should throw an ObjectNotFoundException when namespace does not exist."); } catch (ObjectNotFoundException e) { assertEquals("Namespace \"I_DO_NOT_EXIST\" doesn't exist.", e.getMessage()); } }
@Test public void testUpdateSecurityRoleThatDoesNotExists() { try { securityRoleService.updateSecurityRole(new SecurityRoleKey(SECURITY_ROLE), new SecurityRoleUpdateRequest(DESCRIPTION)); fail("Should throw ObjectNotFoundException when security role does not exist."); } catch (ObjectNotFoundException e) { assertEquals(String.format("Security role with name \"%s\" doesn't exist.", SECURITY_ROLE), e.getMessage()); } }
@Test public void testUpdateStorageStorageNoExists() { // Try to update a storage that doesn't yet exist. try { storageService.updateStorage(new StorageKey(INVALID_VALUE), new StorageUpdateRequest()); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage()); } }
@Test public void testUpdateTagTypeTagTypeNotExists() { // Try to update a tag type instance when display name is not specified. try { tagTypeService.updateTagType(new TagTypeKey(TAG_TYPE), new TagTypeUpdateRequest(TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Tag type with code \"%s\" doesn't exist.", TAG_TYPE), e.getMessage()); } }