use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceExplicitSpotAndSpotPriceNotAvailable.
/**
* Tests algorithmic case when spot is explicitly requested and spot price is not available. The update method should throw an error indicating that no
* subnets satisfied the given criteria.
*/
@Test
public void testBestPriceExplicitSpotAndSpotPriceNotAvailable() {
String subnetId = SUBNET_1;
// For master instance definition, use instance type that does not have spot price available.
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_4);
masterInstanceDefinition.setInstanceSpotPrice(ON_DEMAND);
InstanceDefinition coreInstanceDefinition = null;
InstanceDefinition taskInstanceDefinition = null;
// Try with master failing criteria
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail();
} catch (ObjectNotFoundException e) {
// Set expected EMR VPC price state.
EmrVpcPricingState expectedEmrVpcPricingState = new EmrVpcPricingState();
expectedEmrVpcPricingState.setSubnetAvailableIpAddressCounts(new HashMap<String, Integer>() {
{
put(SUBNET_1, 10);
}
});
expectedEmrVpcPricingState.setSpotPricesPerAvailabilityZone(new HashMap<String, Map<String, BigDecimal>>() {
{
put(AVAILABILITY_ZONE_1, new HashMap<>());
}
});
expectedEmrVpcPricingState.setOnDemandPricesPerAvailabilityZone(new HashMap<String, Map<String, BigDecimal>>() {
{
put(AVAILABILITY_ZONE_1, new HashMap<String, BigDecimal>() {
{
put(INSTANCE_TYPE_4, ON_DEMAND);
}
});
}
});
assertEquals(String.format("There were no subnets which satisfied your best price search criteria. If you explicitly opted to use spot EC2 instances, please confirm " + "that your instance types support spot pricing. Otherwise, try setting the max price or the on-demand threshold to a higher value.%n%s", emrVpcPricingStateFormatter.format(expectedEmrVpcPricingState)), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class SubjectMatterExpertServiceImpl method getSubjectMatterExpert.
@Override
public SubjectMatterExpert getSubjectMatterExpert(SubjectMatterExpertKey subjectMatterExpertKey) {
// Validate and trim the subject matter expert key.
validateSubjectMatterExpertKey(subjectMatterExpertKey);
// Get the information for the subject matter expert.
SubjectMatterExpertContactDetails subjectMatterExpertContactDetails = subjectMatterExpertDao.getSubjectMatterExpertByKey(subjectMatterExpertKey);
if (subjectMatterExpertContactDetails == null) {
throw new ObjectNotFoundException(String.format("The subject matter expert with user id \"%s\" does not exist.", subjectMatterExpertKey.getUserId()));
}
// Create and return the subject matter expert.
return new SubjectMatterExpert(subjectMatterExpertKey, subjectMatterExpertContactDetails);
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class AllowedAttributeValueServiceTest method testDeleteAllowedAttributeValuesNoExists.
@Test
public void testDeleteAllowedAttributeValuesNoExists() {
// Create attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Create namespace entity.
NamespaceEntity namespaceEntity = new NamespaceEntity();
namespaceEntity.setCode(ATTRIBUTE_VALUE_LIST_NAMESPACE);
// Create attribute value list entity.
AttributeValueListEntity attributeValueListEntity = new AttributeValueListEntity();
attributeValueListEntity.setId(ATTRIBUTE_VALUE_LIST_ID);
attributeValueListEntity.setNamespace(namespaceEntity);
attributeValueListEntity.setName(ATTRIBUTE_VALUE_LIST_NAME);
attributeValueListEntity.setAllowedAttributeValues(new ArrayList<>());
// Create allowed attribute value entity.
AllowedAttributeValueEntity allowedAttributeValueEntity = new AllowedAttributeValueEntity();
allowedAttributeValueEntity.setAllowedAttributeValue(ALLOWED_ATTRIBUTE_VALUE);
allowedAttributeValueEntity.setAttributeValueList(attributeValueListEntity);
// Mock calls to external method.
when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity);
when(alternateKeyHelper.validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE)).thenReturn(ALLOWED_ATTRIBUTE_VALUE);
// Try to call method under test.
try {
allowedAttributeValueService.deleteAllowedAttributeValues(new AllowedAttributeValuesDeleteRequest(attributeValueListKey, Arrays.asList(ALLOWED_ATTRIBUTE_VALUE)));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Allowed attribute value \"%s\" doesn't exist in \"%s\" attribute value list.", ALLOWED_ATTRIBUTE_VALUE, attributeValueListEntity.getName()), e.getMessage());
}
// Verify the external calls.
verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey);
verify(alternateKeyHelper).validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE);
verify(attributeValueListHelper).validateAttributeValueListKey(attributeValueListKey);
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataNotificationRegistrationServiceTest method testCreateBusinessObjectDataNotificationRegistrationInvalidParameters.
@Test
public void testCreateBusinessObjectDataNotificationRegistrationInvalidParameters() {
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
BusinessObjectDataNotificationRegistrationCreateRequest request;
// Create and persist the relative database entities.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataNotificationRegistrationTesting();
// Try to create a business object data notification using non-existing namespace.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(new NotificationRegistrationKey("I_DO_NOT_EXIST", NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing namespace.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Namespace \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationRegistrationKey().getNamespace()), e.getMessage());
}
// Try to create a business object data notification when namespace contains a forward slash character.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(new NotificationRegistrationKey(addSlash(NAMESPACE), NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(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 data notification when notification name contains a forward slash character.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE, addSlash(NOTIFICATION_NAME)), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when notification name contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Notification name can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object data notification using non-existing notification event type.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, "I_DO_NOT_EXIST", new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing notification event type.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Notification event type with code \"%s\" doesn't exist.", request.getBusinessObjectDataEventType()), e.getMessage());
}
// Try to create a business object data notification using non-supported notification event type.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NOTIFICATION_EVENT_TYPE, new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when using non-supported notification event type.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Notification event type \"%s\" is not supported for business object data notification registration.", request.getBusinessObjectDataEventType()), e.getMessage());
}
// Try to create a business object data notification using non-existing business object definition name.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing business object definition name.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object definition with name \"%s\" doesn't exist for namespace \"%s\".", request.getBusinessObjectDataNotificationFilter().getBusinessObjectDefinitionName(), request.getBusinessObjectDataNotificationFilter().getNamespace()), e.getMessage());
}
// Try to create a business object data notification using non-existing business object format file type.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing business object format file type.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("File type with code \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationFilter().getBusinessObjectFormatFileType()), e.getMessage());
}
// Try to create a business object data notification using non-existing storage name.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing storage name.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationFilter().getStorageName()), e.getMessage());
}
// Try to create a business object data notification using non-existing new business object data status.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, "I_DO_NOT_EXIST", BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing new business object data status.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object data status \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationFilter().getNewBusinessObjectDataStatus()), e.getMessage());
}
// Try to create a business object data notification using non-existing old business object data status.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, "I_DO_NOT_EXIST"), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing old business object data status.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object data status \"%s\" doesn't exist.", request.getBusinessObjectDataNotificationFilter().getOldBusinessObjectDataStatus()), e.getMessage());
}
// Try to create a business object data notification when using new and old business object data statuses that are the same (case-insensitive).
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS.toUpperCase(), BDATA_STATUS.toLowerCase()), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when using new and old business object data statuses that are the same");
} catch (IllegalArgumentException e) {
assertEquals("The new business object data status is the same as the old one.", e.getMessage());
}
// Try to create a business object data notification for business object data
// registration notification event type with an old business object data status specified.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when old business object data status is specified " + "for a business object data registration notification event type.");
} catch (IllegalArgumentException e) {
assertEquals("The old business object data status cannot be specified with a business object data registration event type.", e.getMessage());
}
// Try to create a business object data notification using non-existing job definition.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), Arrays.asList(new JobAction(NAMESPACE, "I_DO_NOT_EXIST", CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED);
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing job definition.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Job definition with namespace \"%s\" and job name \"%s\" doesn't exist.", request.getJobActions().get(0).getNamespace(), request.getJobActions().get(0).getJobName()), e.getMessage());
}
// Try to create a business object data notification using non-existing notification registration status.
request = new BusinessObjectDataNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), "I_DO_NOT_EXIST");
try {
businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing notification registration status.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("The notification registration status \"%s\" doesn't exist.", request.getNotificationRegistrationStatus()), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataNotificationRegistrationServiceTest method testUpdateBusinessObjectDataNotificationRegistrationNoExists.
@Test
public void testUpdateBusinessObjectDataNotificationRegistrationNoExists() {
// Try to update a non-existing business object data notification registration.
try {
businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, STORAGE_NAME_2, BDATA_STATUS, NO_BDATA_STATUS), notificationRegistrationDaoTestHelper.getTestJobActions2(), NotificationRegistrationStatusEntity.ENABLED));
fail("Should throw an ObjectNotFoundException when trying to update a non-existing business object data notification.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object data notification registration with name \"%s\" does not exist for \"%s\" namespace.", NOTIFICATION_NAME, NAMESPACE), e.getMessage());
}
}
Aggregations