/** * Delegates implementation to {@link org.finra.herd.service.helper.BusinessObjectDataInvalidateUnregisteredHelper}. Keeps current transaction context. * * @param businessObjectDataInvalidateUnregisteredRequest {@link org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest} * * @return {@link BusinessObjectDataInvalidateUnregisteredResponse} */ BusinessObjectDataInvalidateUnregisteredResponse invalidateUnregisteredBusinessObjectDataImpl( BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest) { return businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredRequest); }
validateRequest(businessObjectDataInvalidateUnregisteredRequest); trimRequest(businessObjectDataInvalidateUnregisteredRequest); BusinessObjectFormatEntity businessObjectFormatEntity = getBusinessObjectFormatEntity(businessObjectDataInvalidateUnregisteredRequest); BusinessObjectDataEntity latestBusinessObjectDataEntity = getLatestBusinessObjectDataEntity(businessObjectDataInvalidateUnregisteredRequest); Integer latestBusinessObjectDataVersion = getBusinessObjectDataVersion(latestBusinessObjectDataEntity); getUnregisteredBusinessObjectDataKeys(businessObjectDataInvalidateUnregisteredRequest, storageEntity, businessObjectFormatEntity, latestBusinessObjectDataVersion); registerInvalidBusinessObjectDatas(latestBusinessObjectDataEntity, businessObjectFormatEntity, unregisteredBusinessObjectDataKeys, storageEntity); processBusinessObjectDataStatusChangeNotificationEvents(registeredBusinessObjectDataEntities); return getBusinessObjectDataInvalidateUnregisteredResponse(businessObjectDataInvalidateUnregisteredRequest, registeredBusinessObjectDataEntities);
BusinessObjectDataKey businessObjectDataKey = getBusinessObjectDataKey(request); businessObjectDataKey.setBusinessObjectDataVersion(latestRegisteredBusinessObjectDataVersion + businessObjectDataVersionOffset); List<String> matchingS3ObjectKeys = getS3ObjectKeys(businessObjectFormatEntity, businessObjectDataKey, storageEntity);
/** * Returns the latest version of the business object data registered. Returns null if no data is registered. * * @param businessObjectDataInvalidateUnregisteredRequest request containing business object data key * * @return {@link BusinessObjectDataEntity} or null */ private BusinessObjectDataEntity getLatestBusinessObjectDataEntity( BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest) { BusinessObjectDataKey businessObjectDataKey = getBusinessObjectDataKey(businessObjectDataInvalidateUnregisteredRequest); businessObjectDataKey.setBusinessObjectDataVersion(null); return businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey); }
/** * Constructs the response from the given request and the list of objects that have been registered. * * @param request the original request * @param registeredBusinessObjectDataEntities list of {@link BusinessObjectDataEntity} that have been newly created. * * @return {@link BusinessObjectDataInvalidateUnregisteredResponse} */ private BusinessObjectDataInvalidateUnregisteredResponse getBusinessObjectDataInvalidateUnregisteredResponse( BusinessObjectDataInvalidateUnregisteredRequest request, List<BusinessObjectDataEntity> registeredBusinessObjectDataEntities) { BusinessObjectDataInvalidateUnregisteredResponse response = new BusinessObjectDataInvalidateUnregisteredResponse(); response.setNamespace(request.getNamespace()); response.setBusinessObjectDefinitionName(request.getBusinessObjectDefinitionName()); response.setBusinessObjectFormatUsage(request.getBusinessObjectFormatUsage()); response.setBusinessObjectFormatFileType(request.getBusinessObjectFormatFileType()); response.setBusinessObjectFormatVersion(request.getBusinessObjectFormatVersion()); response.setPartitionValue(request.getPartitionValue()); response.setSubPartitionValues(request.getSubPartitionValues()); response.setStorageName(request.getStorageName()); response.setRegisteredBusinessObjectDataList(getResponseBusinessObjectDatas(registeredBusinessObjectDataEntities)); return response; }
/** * Returns the latest version of the business object data registered. Returns null if no data is registered. * * @param businessObjectDataInvalidateUnregisteredRequest request containing business object data key * * @return {@link BusinessObjectDataEntity} or null */ private BusinessObjectDataEntity getLatestBusinessObjectDataEntity( BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest) { BusinessObjectDataKey businessObjectDataKey = getBusinessObjectDataKey(businessObjectDataInvalidateUnregisteredRequest); businessObjectDataKey.setBusinessObjectDataVersion(null); return businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey); }
/** * Constructs the response from the given request and the list of objects that have been registered. * * @param request the original request * @param registeredBusinessObjectDataEntities list of {@link BusinessObjectDataEntity} that have been newly created. * * @return {@link BusinessObjectDataInvalidateUnregisteredResponse} */ private BusinessObjectDataInvalidateUnregisteredResponse getBusinessObjectDataInvalidateUnregisteredResponse( BusinessObjectDataInvalidateUnregisteredRequest request, List<BusinessObjectDataEntity> registeredBusinessObjectDataEntities) { BusinessObjectDataInvalidateUnregisteredResponse response = new BusinessObjectDataInvalidateUnregisteredResponse(); response.setNamespace(request.getNamespace()); response.setBusinessObjectDefinitionName(request.getBusinessObjectDefinitionName()); response.setBusinessObjectFormatUsage(request.getBusinessObjectFormatUsage()); response.setBusinessObjectFormatFileType(request.getBusinessObjectFormatFileType()); response.setBusinessObjectFormatVersion(request.getBusinessObjectFormatVersion()); response.setPartitionValue(request.getPartitionValue()); response.setSubPartitionValues(request.getSubPartitionValues()); response.setStorageName(request.getStorageName()); response.setRegisteredBusinessObjectDataList(getResponseBusinessObjectDatas(registeredBusinessObjectDataEntities)); return response; }
validateRequest(businessObjectDataInvalidateUnregisteredRequest); trimRequest(businessObjectDataInvalidateUnregisteredRequest); BusinessObjectFormatEntity businessObjectFormatEntity = getBusinessObjectFormatEntity(businessObjectDataInvalidateUnregisteredRequest); BusinessObjectDataEntity latestBusinessObjectDataEntity = getLatestBusinessObjectDataEntity(businessObjectDataInvalidateUnregisteredRequest); Integer latestBusinessObjectDataVersion = getBusinessObjectDataVersion(latestBusinessObjectDataEntity); getUnregisteredBusinessObjectDataKeys(businessObjectDataInvalidateUnregisteredRequest, storageEntity, businessObjectFormatEntity, latestBusinessObjectDataVersion); registerInvalidBusinessObjectDatas(latestBusinessObjectDataEntity, businessObjectFormatEntity, unregisteredBusinessObjectDataKeys, storageEntity); processBusinessObjectDataStatusChangeNotificationEvents(registeredBusinessObjectDataEntities); return getBusinessObjectDataInvalidateUnregisteredResponse(businessObjectDataInvalidateUnregisteredRequest, registeredBusinessObjectDataEntities);
/** * Delegates implementation to {@link org.finra.herd.service.helper.BusinessObjectDataInvalidateUnregisteredHelper}. Keeps current transaction context. * * @param businessObjectDataInvalidateUnregisteredRequest {@link org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest} * * @return {@link BusinessObjectDataInvalidateUnregisteredResponse} */ BusinessObjectDataInvalidateUnregisteredResponse invalidateUnregisteredBusinessObjectDataImpl( BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest) { return businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredRequest); }
BusinessObjectDataKey businessObjectDataKey = getBusinessObjectDataKey(request); businessObjectDataKey.setBusinessObjectDataVersion(latestRegisteredBusinessObjectDataVersion + businessObjectDataVersionOffset); List<String> matchingS3ObjectKeys = getS3ObjectKeys(businessObjectFormatEntity, businessObjectDataKey, storageEntity);
/** * Asserts that business object definition name requiredness validation is working. */ @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); // 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 definition name is required", e.getMessage()); } }
/** * 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()); } }
/** * Asserts that business object format file type requiredness validation is working. */ @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); // 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 file type is required", e.getMessage()); } }
/** * Asserts that storage name requiredness validation is working. */ @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); // 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 storage name is required", e.getMessage()); } }
/** * Asserts that business object format usage requiredness validation is working. */ @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); // 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 usage is required", e.getMessage()); } }
/** * 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()); } }
/** * 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()); } }
/** * 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()); } }
businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown");
businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request); Assert.fail("expected a IllegalArgumentException, but no exception was thrown");