BusinessObjectDataInvalidateUnregisteredHelper { public BusinessObjectDataInvalidateUnregisteredResponse invalidateUnregisteredBusinessObjectData( BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest) { validateRequest(businessObjectDataInvalidateUnregisteredRequest); trimRequest(businessObjectDataInvalidateUnregisteredRequest); BusinessObjectFormatEntity businessObjectFormatEntity = getBusinessObjectFormatEntity(businessObjectDataInvalidateUnregisteredRequest); String storageName = businessObjectDataInvalidateUnregisteredRequest.getStorageName(); StorageEntity storageEntity = storageDaoHelper.getStorageEntity(storageName); if (!StoragePlatformEntity.S3.equals(storageEntity.getStoragePlatform().getName())) { throw new IllegalArgumentException("The specified storage '" + storageName + "' is not an S3 storage platform."); } BusinessObjectDataEntity latestBusinessObjectDataEntity = getLatestBusinessObjectDataEntity(businessObjectDataInvalidateUnregisteredRequest); Integer latestBusinessObjectDataVersion = getBusinessObjectDataVersion(latestBusinessObjectDataEntity); List<BusinessObjectDataKey> unregisteredBusinessObjectDataKeys = getUnregisteredBusinessObjectDataKeys(businessObjectDataInvalidateUnregisteredRequest, storageEntity, businessObjectFormatEntity, latestBusinessObjectDataVersion); List<BusinessObjectDataEntity> registeredBusinessObjectDataEntities = registerInvalidBusinessObjectDatas(latestBusinessObjectDataEntity, businessObjectFormatEntity, unregisteredBusinessObjectDataKeys, storageEntity); processBusinessObjectDataStatusChangeNotificationEvents(registeredBusinessObjectDataEntities); return getBusinessObjectDataInvalidateUnregisteredResponse(businessObjectDataInvalidateUnregisteredRequest, registeredBusinessObjectDataEntities); }  BusinessObjectDataInvalidateUnregisteredResponse invalidateUnregisteredBusinessObjectData(
        BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest); static final String UNREGISTERED_STATUS; }
@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); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); 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()); }
@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); 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); } BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList()); Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size()); }
@Test public void testInvalidateUnregisteredBusinessObjectDataS31Herd0() 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); 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); } BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); 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()); } } }
@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); 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); } BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); 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()); } } }
@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); 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); } BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); 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()); } } }
@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); 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); } BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList()); Assert.assertEquals("response business object datas size", 2, 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()); } } { 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()); } } }
@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); 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); } BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList()); Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size()); }
@Test public void testInvalidateUnregisteredBusinessObjectDataS3PrefixWithSlash() 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); BusinessObjectFormatEntity businessObjectFormatEntity; try { businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); request.setPartitionValue("AA"); businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 0); request.setPartitionValue("A"); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList()); Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size()); }
@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); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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()); } }
@Test public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectDefinitionNameRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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 definition name is required", e.getMessage()); } }
@Test public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatUsageRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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 usage is required", e.getMessage()); } }
@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); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } request.setBusinessObjectFormatFileType("DOES_NOT_EXIST"); 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()); } }
@Test public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatFileTypeRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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 file type is required", e.getMessage()); } }
@Test public void testInvalidateUnregisteredBusinessObjectDataValidationBusinessObjectFormatVersionRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } request.setBusinessObjectFormatVersion(null); 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 is required", e.getMessage()); } }
@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); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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()); } }
@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); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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()); } }
@Test public void testInvalidateUnregisteredBusinessObjectDataValidationStorageNameRequired() { BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BLANK_TEXT); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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 storage name is required", e.getMessage()); } }
@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"); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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()); } }
@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); 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); } 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()); } }
@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); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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()); } }
@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); try { businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request); } catch (Exception e) { throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e); } 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); BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); 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()); }