use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testSearchBusinessObjectDefinitionInvalidParams.
@Test
public void testSearchBusinessObjectDefinitionInvalidParams() {
// Try to search business object definition when empty search filter is specified.
try {
businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter())), NO_SEARCH_RESPONSE_FIELDS);
fail();
} catch (IllegalArgumentException e) {
assertEquals("Exactly one business object definition search key must be specified.", e.getMessage());
}
// Try to search business object definition when there are more than one business object definition search filter is specified.
try {
businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(), new BusinessObjectDefinitionSearchFilter())), NO_SEARCH_RESPONSE_FIELDS);
fail();
} catch (IllegalArgumentException e) {
assertEquals("Exactly one business object definition search filter must be specified.", e.getMessage());
}
// Try to search business object definition when there are more than one business object definition search key is specified.
try {
businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(), new BusinessObjectDefinitionSearchKey())))), NO_SEARCH_RESPONSE_FIELDS);
fail();
} catch (IllegalArgumentException e) {
assertEquals("Exactly one business object definition search key must be specified.", e.getMessage());
}
// Try to search business object definitions for a non-existing tag type.
try {
businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey("I_DO_NOT_EXIST", "I_DO_NO_EXIST"), NOT_INCLUDE_TAG_HIERARCHY))))), NO_SEARCH_RESPONSE_FIELDS);
fail();
} catch (ObjectNotFoundException e) {
assertEquals("Tag with code \"I_DO_NO_EXIST\" doesn't exist for tag type \"I_DO_NOT_EXIST\".", e.getMessage());
}
// Try to retrieve the actual business object definition objects using an un-supported search field.
try {
businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet("I_DO_NOT_EXIST"));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Search response field \"i_do_not_exist\" is not supported.", e.getMessage());
}
// Try to retrieve the actual business object definition object using an un-supported search field in the mix of supported search fields.
try {
businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet(FIELD_DISPLAY_NAME, "I_DO_NOT_EXIST", FIELD_DATA_PROVIDER_NAME));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Search response field \"i_do_not_exist\" is not supported.", e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionDescriptiveInformationBusinessObjectDefinitionNoExists.
@Test
public void testUpdateBusinessObjectDefinitionDescriptiveInformationBusinessObjectDefinitionNoExists() throws Exception {
// Try to update business object definition descriptive information for a non-existing business object definition.
try {
businessObjectDefinitionService.updateBusinessObjectDefinitionDescriptiveInformation(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionDescriptiveInformationUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DESCRIPTION_2, NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT_UPDATE_REQUEST));
fail("Should throw an ObjectNotFoundException when business object definition doesn't exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object definition with name \"%s\" doesn't exist for namespace \"%s\".", BDEF_NAME, BDEF_NAMESPACE), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testGetBusinessObjectDefinitionNoExists.
@Test
public void testGetBusinessObjectDefinitionNoExists() throws Exception {
// Try to get a non-existing business object definition.
try {
businessObjectDefinitionService.getBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
fail("Should throw an ObjectNotFoundException when business object definition doesn't exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object definition with name \"%s\" doesn't exist for namespace \"%s\".", BDEF_NAME, NAMESPACE), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionInvalidParameters.
@Test
public void testCreateBusinessObjectDefinitionInvalidParameters() {
BusinessObjectDefinitionCreateRequest request;
// Create and persist database entities required for testing.
businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
// Try to create a business object definition using non-existing namespace.
request = new BusinessObjectDefinitionCreateRequest("I_DO_NOT_EXIST", BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an ObjectNotFoundException when using non-existing namespace.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Namespace \"%s\" doesn't exist.", request.getNamespace()), e.getMessage());
}
// Try to create a business object definition when namespace contains a forward slash character.
request = new BusinessObjectDefinitionCreateRequest(addSlash(BDEF_NAMESPACE), BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an IllegalArgumentException when namespace contains a forward slash character");
} catch (IllegalArgumentException e) {
assertEquals("Namespace can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition when business object definition name contains a forward slash character.
request = new BusinessObjectDefinitionCreateRequest(BDEF_NAMESPACE, addSlash(BDEF_NAME), DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an IllegalArgumentException when business object definition name contains a forward slash character");
} catch (IllegalArgumentException e) {
assertEquals("Business object definition name can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition using non-existing data provider.
request = new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an ObjectNotFoundException when using non-existing data provider name.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Data provider with name \"%s\" doesn't exist.", request.getDataProviderName()), e.getMessage());
}
// Try to create a business object definition when data provider name contains a forward slash character.
request = new BusinessObjectDefinitionCreateRequest(BDEF_NAMESPACE, BDEF_NAME, addSlash(DATA_PROVIDER_NAME), BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an IllegalArgumentException when data provider name contains a forward slash character");
} catch (IllegalArgumentException e) {
assertEquals("Data provider name can not contain a forward slash character.", e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataStorageNotFound.
@Test
public void testCreateBusinessObjectDataStorageNotFound() {
// Create relative database entities.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Build a business object data create request with a non-existing storage name.
String invalidStorageName = "I_DO_NOT_EXIST";
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, invalidStorageName, testS3KeyPrefix, businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, Arrays.asList(LOCAL_FILE)));
try {
// Try to create a business object data instance using a non-existing storage.
businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest);
fail("Should throw an ObjectNotFoundException when specified storage name does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", invalidStorageName), e.getMessage());
}
}
Aggregations