Search in sources :

Example 26 with BusinessObjectDataInvalidateUnregisteredRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.

the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataTrim.

/**
 * Asserts that values are trimmed before the request is processed.
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataTrim() throws Exception {
    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
    try {
        businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
    } catch (Exception e) {
        throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e);
    }
    // pad string values with white spaces
    request.setNamespace(BLANK_TEXT + request.getNamespace() + BLANK_TEXT);
    request.setBusinessObjectDefinitionName(BLANK_TEXT + request.getBusinessObjectDefinitionName() + BLANK_TEXT);
    request.setBusinessObjectFormatFileType(BLANK_TEXT + request.getBusinessObjectFormatFileType() + BLANK_TEXT);
    request.setBusinessObjectFormatUsage(BLANK_TEXT + request.getBusinessObjectFormatUsage() + BLANK_TEXT);
    request.setPartitionValue(BLANK_TEXT + request.getPartitionValue() + BLANK_TEXT);
    List<String> paddedSubPartitionValues = new ArrayList<>();
    for (String subPartitionValue : request.getSubPartitionValues()) {
        paddedSubPartitionValues.add(BLANK_TEXT + subPartitionValue + BLANK_TEXT);
    }
    request.setSubPartitionValues(paddedSubPartitionValues);
    // Call the API
    BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request);
    // Make assertions
    /*
             * Note: The API will modify the request to now contain the trimmed value.
             */
    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());
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) ArrayList(java.util.ArrayList) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 27 with BusinessObjectDataInvalidateUnregisteredRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.

the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataS31Herd0WithSubPartitions.

/**
 * Test case where S3 has 1 object, and herd has no object registered. The data has sub-partitions. Expects one new registration in INVALID status.
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataS31Herd0WithSubPartitions() throws Exception {
    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, 0);
    } 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 sub-partition values is null", actualResponse.getSubPartitionValues());
    Assert.assertEquals("response sub-partition values", request.getSubPartitionValues(), actualResponse.getSubPartitionValues());
    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", 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());
        }
    }
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 28 with BusinessObjectDataInvalidateUnregisteredRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.

the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataS31Herd1.

/**
 * Test case where herd and S3 are in sync because both have 1 object registered. Expects no new data registration.
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataS31Herd1() 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 {
        BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
        businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 0);
        createBusinessObjectDataEntityFromBusinessObjectDataInvalidateUnregisteredRequest(businessObjectFormatEntity, request, 0, true);
    } 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 business object datas is null", actualResponse.getRegisteredBusinessObjectDataList());
    Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size());
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 29 with BusinessObjectDataInvalidateUnregisteredRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.

the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataValidationNamespaceRequired.

/**
 * Asserts that namespace requiredness validation is working.
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataValidationNamespaceRequired() {
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    request.setNamespace(BLANK_TEXT);
    // 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 namespace is required", e.getMessage());
    }
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 30 with BusinessObjectDataInvalidateUnregisteredRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest in project herd by FINRAOS.

the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataValidationPartitionValueRequired.

/**
 * Asserts that partition value requiredness validation is working.
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataValidationPartitionValueRequired() {
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, BLANK_TEXT, 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 partition value is required", e.getMessage());
    }
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Aggregations

BusinessObjectDataInvalidateUnregisteredRequest (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest)32 Test (org.junit.Test)31 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)21 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)21 BusinessObjectDataInvalidateUnregisteredResponse (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse)13 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)12 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)4 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)4 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)4 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)4 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)4 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 MessageHeaderDefinition (org.finra.herd.model.api.xml.MessageHeaderDefinition)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 NotificationMessage (org.finra.herd.model.dto.NotificationMessage)3 BusinessObjectDataAvailabilityCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionRequest)1 BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)1