use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityPartitionValueListPartitionValueTokensNoPartitionValueExists.
@Test
public void testCheckBusinessObjectDataAvailabilityPartitionValueListPartitionValueTokensNoPartitionValueExists() {
// Prepare test data.
businessObjectDataAvailabilityTestHelper.createDatabaseEntitiesForBusinessObjectDataAvailabilityTesting(null);
// column when all business object data is registered using only primary partition.
for (String partitionValueToken : Arrays.asList(BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN, BusinessObjectDataService.MIN_PARTITION_VALUE_TOKEN)) {
BusinessObjectDataAvailabilityRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(null);
List<PartitionValueFilter> partitionValueFilters = new ArrayList<>();
request.setPartitionValueFilters(partitionValueFilters);
partitionValueFilters.add(new PartitionValueFilter(SECOND_PARTITION_COLUMN_NAME, Arrays.asList(partitionValueToken), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE));
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Suppose to throw an ObjectNotFoundException when failed to find a maximum partition value.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Failed to find %s partition value for partition key = \"%s\" due to no available business object data " + "in \"%s\" storage(s) that is registered using that partition. Business object data {namespace: \"%s\", " + "businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", businessObjectFormatFileType: \"%s\", " + "businessObjectFormatVersion: %d, businessObjectDataVersion: %d}", partitionValueToken.equals(BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN) ? "maximum" : "minimum", SECOND_PARTITION_COLUMN_NAME, STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, DATA_VERSION), e.getMessage());
}
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityInvalidParameters.
@Test
public void testCheckBusinessObjectDataAvailabilityInvalidParameters() {
BusinessObjectDataAvailabilityRequest request;
// Prepare test data.
businessObjectDataAvailabilityTestHelper.createDatabaseEntitiesForBusinessObjectDataAvailabilityTesting(null);
// Try to check business object data availability using non-existing format.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
request.setBusinessObjectDefinitionName("I_DO_NOT_EXIST");
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an ObjectNotFoundException when non-existing business object format is used.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(request.getNamespace(), request.getBusinessObjectDefinitionName(), request.getBusinessObjectFormatUsage(), request.getBusinessObjectFormatFileType(), request.getBusinessObjectFormatVersion()), e.getMessage());
}
// Try to check business object data availability using non-existing partition key (partition column).
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
request.getPartitionValueFilters().get(0).setPartitionKey("I_DO_NOT_EXIST");
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when non-existing partition key is used.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("The partition key \"%s\" does not exist in first %d partition columns in the schema for business object format " + "{namespace: \"%s\", businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", businessObjectFormatFileType: \"%s\", " + "businessObjectFormatVersion: %d}.", request.getPartitionValueFilters().get(0).getPartitionKey(), BusinessObjectDataEntity.MAX_SUBPARTITIONS + 1, request.getNamespace(), request.getBusinessObjectDefinitionName(), request.getBusinessObjectFormatUsage(), request.getBusinessObjectFormatFileType(), request.getBusinessObjectFormatVersion()), e.getMessage());
}
// Try to check business object data availability when both partition value filter and partition value filter list are specified.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
request.setPartitionValueFilter(new PartitionValueFilter(FIRST_PARTITION_COLUMN_NAME.toUpperCase(), new ArrayList<>(UNSORTED_PARTITION_VALUES), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE));
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when both a list of partition value filters and a standalone partition value filter are specified.");
} catch (IllegalArgumentException e) {
assertEquals("A list of partition value filters and a standalone partition value filter cannot be both specified.", e.getMessage());
}
// Try to check business object data availability when partition value filter has none or more than one partition value filter option specified.
for (PartitionValueFilter partitionValueFilter : businessObjectDataServiceTestHelper.getInvalidPartitionValueFilters()) {
request = new BusinessObjectDataAvailabilityRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Arrays.asList(partitionValueFilter), NO_STANDALONE_PARTITION_VALUE_FILTER, DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS);
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when partition value filter has more than one partition value filter option.");
} catch (IllegalArgumentException e) {
assertEquals("Exactly one partition value filter option must be specified.", e.getMessage());
}
}
// Try to check business object data availability when partition value token is specified with a partition value range.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN, END_PARTITION_VALUE);
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when partition value token is specified with a partition value range.");
} catch (IllegalArgumentException e) {
assertEquals("A partition value token cannot be specified with a partition value range.", e.getMessage());
}
// Try to check business object data availability when partition value token is specified with a partition value range.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(BusinessObjectDataService.MIN_PARTITION_VALUE_TOKEN, END_PARTITION_VALUE);
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when partition value token is specified with a partition value range.");
} catch (IllegalArgumentException e) {
assertEquals("A partition value token cannot be specified with a partition value range.", e.getMessage());
}
// Try to check business object data availability when partition value token is specified with a partition value range.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(START_PARTITION_VALUE, BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN);
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when partition value token is specified with a partition value range.");
} catch (IllegalArgumentException e) {
assertEquals("A partition value token cannot be specified with a partition value range.", e.getMessage());
}
// Try to check business object data availability when partition value token is specified with a partition value range.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(END_PARTITION_VALUE, BusinessObjectDataService.MIN_PARTITION_VALUE_TOKEN);
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when partition value token is specified with a partition value range.");
} catch (IllegalArgumentException e) {
assertEquals("A partition value token cannot be specified with a partition value range.", e.getMessage());
}
// Try to check business object data availability when partition value filter has start partition value which is greater than the end partition value.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(END_PARTITION_VALUE, START_PARTITION_VALUE);
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when start partition value which is greater than the end partition value.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("The start partition value \"%s\" cannot be greater than the end partition value \"%s\".", END_PARTITION_VALUE, START_PARTITION_VALUE), e.getMessage());
}
// Try to check business object data availability when both a list of storage names and standalone storage name are specified.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
request.setStorageName(BLANK_TEXT);
request.setStorageNames(STORAGE_NAMES);
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an IllegalArgumentException when both a list of storage names and standalone storage name are specified.");
} catch (IllegalArgumentException e) {
assertEquals("A list of storage names and a standalone storage name cannot be both specified.", e.getMessage());
}
// Try to check business object data availability passing a non-existing storage as a standalone storage name.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
request.setStorageName("I_DO_NOT_EXIST");
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an ObjectNotFoundException when non-existing storage is used as a standalone storage name.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", request.getStorageName()), e.getMessage());
}
// Try to check business object data availability passing a non-existing storage in the list of storage names.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
request.setStorageName(null);
request.setStorageNames(Arrays.asList("I_DO_NOT_EXIST"));
try {
businessObjectDataService.checkBusinessObjectDataAvailability(request);
fail("Should throw an ObjectNotFoundException when non-existing storage is used in the list of storage names.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", request.getStorageNames().get(0)), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlIncludeAllRegisteredSubPartitionsSecondSubPartitionInvalidBdataArchived.
@Test
public void testGenerateBusinessObjectDataDdlIncludeAllRegisteredSubPartitionsSecondSubPartitionInvalidBdataArchived() {
// Create two VALID sub-partitions both with "available" storage units.
List<StorageUnitEntity> storageUnitEntities = businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTestingTwoPartitionLevels(Arrays.asList(Arrays.asList(PARTITION_VALUE, SUB_PARTITION_VALUE_1), Arrays.asList(PARTITION_VALUE, SUB_PARTITION_VALUE_2)));
// Update the second sub-partition business object data status to INVALID.
storageUnitEntities.get(1).getBusinessObjectData().setStatus(businessObjectDataStatusDao.getBusinessObjectDataStatusByCode(BusinessObjectDataStatusEntity.INVALID));
// Update the second sub-partition storage unit status to ARCHIVED.
storageUnitEntities.get(1).setStatus(storageUnitStatusDao.getStorageUnitStatusByCode(StorageUnitStatusEntity.ARCHIVED));
// Try to retrieve business object data DDL with "IncludeAllRegisteredSubPartitions" option enabled.
try {
businessObjectDataService.generateBusinessObjectDataDdl(new BusinessObjectDataDdlRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(FIRST_PARTITION_COLUMN_NAME, Arrays.asList(PARTITION_VALUE), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE)), NO_STANDALONE_PARTITION_VALUE_FILTER, NO_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL, TABLE_NAME, NO_CUSTOM_DDL_NAME, INCLUDE_DROP_TABLE_STATEMENT, INCLUDE_IF_NOT_EXISTS_OPTION, INCLUDE_DROP_PARTITIONS, NO_ALLOW_MISSING_DATA, INCLUDE_ALL_REGISTERED_SUBPARTITIONS, NO_SUPPRESS_SCAN_FOR_UNREGISTERED_SUBPARTITIONS));
fail("Suppose to throw an ObjectNotFoundException when second sub-partition has a non-available storage unit status.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object data {namespace: \"%s\", businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", " + "businessObjectFormatFileType: \"%s\", businessObjectFormatVersion: %d, partitionValue: \"%s\", " + "subpartitionValues: \"%s\", businessObjectDataVersion: %d} is not available in \"%s\" storage(s).", NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, FORMAT_VERSION, PARTITION_VALUE, SUB_PARTITION_VALUE_2, DATA_VERSION, STORAGE_NAME), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataServiceDeleteBusinessObjectDataTest method testDeleteBusinessObjectDataInvalidParameters.
@Test
public void testDeleteBusinessObjectDataInvalidParameters() {
// Create and persist a valid business object data.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
// Validate that this business object data exists.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
assertNotNull(businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey));
// Try to perform a delete using invalid namespace.
try {
businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey("I_DO_NOT_EXIST", BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), false);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage("I_DO_NOT_EXIST", BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a delete using invalid business object definition name.
try {
businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), false);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a delete using invalid format usage.
try {
businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), false);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a delete using invalid format file type.
try {
businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), false);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a delete using invalid business object format version.
try {
businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), false);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a delete using invalid partition value.
try {
businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, DATA_VERSION), false);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a delete using invalid subpartition value.
for (int i = 0; i < SUBPARTITION_VALUES.size(); i++) {
List<String> testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
testSubPartitionValues.set(i, "I_DO_NOT_EXIST");
try {
businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION), false);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION, null), e.getMessage());
}
}
// Try to perform a delete using invalid business object data version.
try {
businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION), false);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION, null), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataInvalidParameters.
@Test
public void testGetBusinessObjectDataInvalidParameters() {
// Create and persist a valid business object data.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
// Validate that we can perform a get on our business object data.
BusinessObjectData resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS, resultBusinessObjectData);
// Try to perform a get using invalid business object definition name.
try {
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
}
// Try to perform a get using invalid format usage.
try {
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
}
// Try to perform a get using invalid format file type.
try {
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
}
// Try to perform a get using invalid partition key.
try {
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), "I_DO_NOT_EXIST", NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an IllegalArgumentException when using an invalid partition key.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Partition key \"%s\" doesn't match configured business object format partition key \"%s\".", "I_DO_NOT_EXIST", PARTITION_KEY), e.getMessage());
}
// Try to perform a get using invalid partition value.
try {
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
}
// Try to perform a get using invalid subpartition value.
for (int i = 0; i < SUBPARTITION_VALUES.size(); i++) {
List<String> testSubPartitionValues = new ArrayList<>();
try {
testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
testSubPartitionValues.set(i, "I_DO_NOT_EXIST");
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
}
}
// Try to perform a get using too many subpartition values.
try {
List<String> testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
testSubPartitionValues.add("EXTRA_SUBPARTITION_VALUE");
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an IllegalArgumentException when passing too many subpartition values.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Exceeded maximum number of allowed subpartitions: %d.", BusinessObjectDataEntity.MAX_SUBPARTITIONS), e.getMessage());
}
// Try to perform a get using invalid business object format version.
try {
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
}
// Try to perform a get using invalid business object data version.
try {
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
}
// Try to perform a get using an invalid business object data status.
try {
businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION), PARTITION_KEY, BDATA_STATUS_2, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an ObjectNotFoundException when not able to find business object data status.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object data status \"%s\" doesn't exist.", BDATA_STATUS_2), e.getMessage());
}
}
Aggregations