use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class MessageNotificationEventServiceTest method testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageDestination.
@Test
public void testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageDestination() throws Exception {
// Create a business object format entity.
BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
// Get a business object data key.
BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity);
// Override configuration, so there will be no message definition specified in the relative notification message definition.
ConfigurationEntity configurationEntity = new ConfigurationEntity();
configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey());
configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList(new NotificationMessageDefinition(MESSAGE_TYPE, NO_MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
configurationDao.saveAndRefresh(configurationEntity);
// Try to trigger the notification.
try {
// Trigger the notification.
messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION);
fail();
} catch (IllegalStateException e) {
assertEquals(String.format("Notification message destination must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataS32Herd1.
/**
* Test case where S3 has 2 objects, and herd has 1 object registered. Expects one new registration in INVALID status.
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataS32Herd1() throws Exception {
BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
// Given a business object format
// Given 1 business object data registered
// Given 2 S3 objects
BusinessObjectFormatEntity businessObjectFormatEntity;
try {
businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
createBusinessObjectDataEntityFromBusinessObjectDataInvalidateUnregisteredRequest(businessObjectFormatEntity, request, 0, true);
businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 0);
businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 1);
} catch (Exception e) {
throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e);
}
// Call API
BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request);
// Make assertions
Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList());
Assert.assertEquals("response business object datas size", 1, actualResponse.getRegisteredBusinessObjectDataList().size());
{
BusinessObjectData businessObjectData = actualResponse.getRegisteredBusinessObjectDataList().get(0);
Assert.assertEquals("response business object data[0] version", 1, businessObjectData.getVersion());
Assert.assertEquals("response business object data[0] status", BusinessObjectDataInvalidateUnregisteredHelper.UNREGISTERED_STATUS, businessObjectData.getStatus());
Assert.assertNotNull("response business object data[0] storage units is null", businessObjectData.getStorageUnits());
Assert.assertEquals("response business object data[0] storage units size", 1, businessObjectData.getStorageUnits().size());
{
String expectedS3KeyPrefix = s3KeyPrefixHelper.buildS3KeyPrefix(S3_KEY_PREFIX_VELOCITY_TEMPLATE, businessObjectFormatEntity, businessObjectDataHelper.createBusinessObjectDataKey(businessObjectData), STORAGE_NAME);
StorageUnit storageUnit = businessObjectData.getStorageUnits().get(0);
Assert.assertNotNull("response business object data[0] storage unit[0] storage directory is null", storageUnit.getStorageDirectory());
Assert.assertEquals("response business object data[0] storage unit[0] storage directory path", expectedS3KeyPrefix, storageUnit.getStorageDirectory().getDirectoryPath());
}
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataS31Herd0WithGap.
/**
* Test case where S3 has 1 object, and herd has no object registered. The S3 object is registered under version 1 so there is a gap for version 0 of
* registration. Expects no new registrations since the API does not consider the S3 objects after a gap.
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataS31Herd0WithGap() {
BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
// Given a business object format
// Given an object in S3
BusinessObjectFormatEntity businessObjectFormatEntity;
try {
businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 1);
} catch (Exception e) {
throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e);
}
// Call API
BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request);
// Make assertions
Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList());
Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataValidationSubPartitionValueNotBlank.
/**
* If sub-partition values are given, they must not be blank.
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataValidationSubPartitionValueNotBlank() {
BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(BLANK_TEXT), StorageEntity.MANAGED_STORAGE);
// Given a business object format
try {
businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
} catch (Exception e) {
throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e);
}
// Call the API
try {
businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request);
Assert.fail("expected a IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass());
Assert.assertEquals("thrown exception message", "The sub-partition value [0] must not be blank", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataS30Herd0.
/**
* Test case where S3 and herd are in sync because there are no data in either S3 or herd. Expects no new registrations. This is a happy path where common
* response values are asserted.
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataS30Herd0() throws Exception {
BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
// Given a business object format
try {
businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
} catch (Exception e) {
throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e);
}
// Call the API
BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request);
// Make assertions
Assert.assertNotNull("response is null", actualResponse);
Assert.assertEquals("response namespace", request.getNamespace(), actualResponse.getNamespace());
Assert.assertEquals("response business object definition name", request.getBusinessObjectDefinitionName(), actualResponse.getBusinessObjectDefinitionName());
Assert.assertEquals("response business object format usage", request.getBusinessObjectFormatUsage(), actualResponse.getBusinessObjectFormatUsage());
Assert.assertEquals("response business object format file type", request.getBusinessObjectFormatFileType(), actualResponse.getBusinessObjectFormatFileType());
Assert.assertEquals("response business object format version", request.getBusinessObjectFormatVersion(), actualResponse.getBusinessObjectFormatVersion());
Assert.assertEquals("response partition value", request.getPartitionValue(), actualResponse.getPartitionValue());
Assert.assertEquals("response sub-partition values", request.getSubPartitionValues(), actualResponse.getSubPartitionValues());
Assert.assertEquals("response storage name", request.getStorageName(), actualResponse.getStorageName());
Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList());
Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size());
}
Aggregations