use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatVersionNegative.
/**
* Asserts that business object format version positive validation is working.
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatVersionNegative() {
BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, -1, 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
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 business object format version must be greater than or equal to 0", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataValidationStoragePlatformMustBeS3.
/**
* Storage is found, but the storage platform is not S3. This API only works for S3 platforms since it requires S3 key prefix.
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataValidationStoragePlatformMustBeS3() {
BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, STORAGE_NAME);
// Given a business object format
try {
storageDaoTestHelper.createStorageEntity(request.getStorageName(), "NOT_S3");
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 specified storage '" + request.getStorageName() + "' is not an S3 storage platform.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataValidationStorageMustExist.
/**
* Storage must exist for this API to work.
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataValidationStorageMustExist() {
BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, "DOES_NOT_EXIST");
// 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 ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", ObjectNotFoundException.class, e.getClass());
Assert.assertEquals("thrown exception message", "Storage with name \"" + request.getStorageName() + "\" doesn't exist.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatMustExist.
/**
* Business object format must exist for this API to work
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatMustExist() {
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);
}
// Modify a parameter specific to a format to reference a format that does not exist
request.setBusinessObjectFormatFileType("DOES_NOT_EXIST");
// Call the API
try {
businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request);
Assert.fail("expected a ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", ObjectNotFoundException.class, e.getClass());
Assert.assertEquals("thrown exception message", "Business object format with namespace \"" + request.getNamespace() + "\", business object definition name \"" + request.getBusinessObjectDefinitionName() + "\", format usage \"" + request.getBusinessObjectFormatUsage() + "\", format file type \"" + request.getBusinessObjectFormatFileType() + "\", and format version \"" + request.getBusinessObjectFormatVersion() + "\" doesn't exist.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataS32Herd0.
/**
* Test case where S3 has 2 objects, but herd has no object registered. Expects 2 new registrations in INVALID status.
*/
@Test
public void testInvalidateUnregisteredBusinessObjectDataS32Herd0() 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);
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", 2, actualResponse.getRegisteredBusinessObjectDataList().size());
// Assert first data registered
{
BusinessObjectData businessObjectData = actualResponse.getRegisteredBusinessObjectDataList().get(0);
Assert.assertEquals("response business object data[0] version", 0, 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());
}
}
// Assert second data registered
{
BusinessObjectData businessObjectData = actualResponse.getRegisteredBusinessObjectDataList().get(1);
Assert.assertEquals("response business object data[1] version", 1, businessObjectData.getVersion());
Assert.assertEquals("response business object data[1] status", BusinessObjectDataInvalidateUnregisteredHelper.UNREGISTERED_STATUS, businessObjectData.getStatus());
Assert.assertNotNull("response business object data[1] storage units is null", businessObjectData.getStorageUnits());
Assert.assertEquals("response business object data[1] 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[1] storage unit[0] storage directory is null", storageUnit.getStorageDirectory());
Assert.assertEquals("response business object data[1] storage unit[0] storage directory path", expectedS3KeyPrefix, storageUnit.getStorageDirectory().getDirectoryPath());
}
}
}
Aggregations