use of org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest in project herd by FINRAOS.
the class DataBridgeWebClient method updateBusinessObjectDataStatus.
/**
* Updates the business object data status.
*
* @param businessObjectDataKey the business object data key
* @param businessObjectDataStatus the status of the business object data
*
* @return {@link org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse}
* @throws URISyntaxException When error occurs while URI creation
* @throws IOException When error occurs communicating with server
* @throws JAXBException When error occurs parsing the XML
*/
public BusinessObjectDataStatusUpdateResponse updateBusinessObjectDataStatus(BusinessObjectDataKey businessObjectDataKey, String businessObjectDataStatus) throws URISyntaxException, IOException, JAXBException {
BusinessObjectDataStatusUpdateRequest request = new BusinessObjectDataStatusUpdateRequest();
request.setStatus(businessObjectDataStatus);
// Create a JAXB context and marshaller
JAXBContext requestContext = JAXBContext.newInstance(BusinessObjectDataStatusUpdateRequest.class);
Marshaller requestMarshaller = requestContext.createMarshaller();
requestMarshaller.setProperty(Marshaller.JAXB_ENCODING, StandardCharsets.UTF_8.name());
requestMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
StringWriter sw = new StringWriter();
requestMarshaller.marshal(request, sw);
BusinessObjectDataStatusUpdateResponse businessObjectDataStatusUpdateResponse;
try (CloseableHttpClient client = httpClientOperations.createHttpClient()) {
StringBuilder uriPathBuilder = new StringBuilder(300);
uriPathBuilder.append(HERD_APP_REST_URI_PREFIX + "/businessObjectDataStatus/namespaces/").append(businessObjectDataKey.getNamespace());
uriPathBuilder.append("/businessObjectDefinitionNames/").append(businessObjectDataKey.getBusinessObjectDefinitionName());
uriPathBuilder.append("/businessObjectFormatUsages/").append(businessObjectDataKey.getBusinessObjectFormatUsage());
uriPathBuilder.append("/businessObjectFormatFileTypes/").append(businessObjectDataKey.getBusinessObjectFormatFileType());
uriPathBuilder.append("/businessObjectFormatVersions/").append(businessObjectDataKey.getBusinessObjectFormatVersion());
uriPathBuilder.append("/partitionValues/").append(businessObjectDataKey.getPartitionValue());
for (int i = 0; i < org.apache.commons.collections4.CollectionUtils.size(businessObjectDataKey.getSubPartitionValues()) && i < BusinessObjectDataEntity.MAX_SUBPARTITIONS; i++) {
uriPathBuilder.append("/subPartition").append(i + 1).append("Values/").append(businessObjectDataKey.getSubPartitionValues().get(i));
}
uriPathBuilder.append("/businessObjectDataVersions/").append(businessObjectDataKey.getBusinessObjectDataVersion());
URIBuilder uriBuilder = new URIBuilder().setScheme(getUriScheme()).setHost(regServerAccessParamsDto.getRegServerHost()).setPort(regServerAccessParamsDto.getRegServerPort()).setPath(uriPathBuilder.toString());
HttpPut httpPut = new HttpPut(uriBuilder.build());
httpPut.addHeader("Content-Type", DEFAULT_CONTENT_TYPE);
httpPut.addHeader("Accepts", DEFAULT_ACCEPT);
if (regServerAccessParamsDto.isUseSsl()) {
httpPut.addHeader(getAuthorizationHeader());
}
httpPut.setEntity(new StringEntity(sw.toString()));
LOGGER.info(String.format(" HTTP POST URI: %s", httpPut.getURI().toString()));
LOGGER.info(String.format(" HTTP POST Headers: %s", Arrays.toString(httpPut.getAllHeaders())));
LOGGER.info(String.format(" HTTP POST Entity Content:%n%s", sw.toString()));
businessObjectDataStatusUpdateResponse = getBusinessObjectDataStatusUpdateResponse(httpClientOperations.execute(client, httpPut));
}
LOGGER.info("Successfully updated status of the business object data.");
return businessObjectDataStatusUpdateResponse;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDataStatusServiceTest method testUpdateBusinessObjectDataStatusMissingRequiredParameters.
@Test
public void testUpdateBusinessObjectDataStatusMissingRequiredParameters() {
// Try to update the business object data status when business object definition name is not specified.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object definition name must be specified.", e.getMessage());
}
// Try to update the business object data status instance when business object format usage is not specified.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when business object format usage is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format usage must be specified.", e.getMessage());
}
// Try to update the business object data status when business object format file type is not specified.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when business object format file type is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format file type must be specified.", e.getMessage());
}
// Try to update the business object data status when business object format version is not specified.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when business object format version is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format version must be specified.", e.getMessage());
}
// Try to update the business object data status when partition value is not specified.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, BLANK_TEXT, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when partition value is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A partition value must be specified.", e.getMessage());
}
// Try to update the business object data status without specifying 1st subpartition value.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(BLANK_TEXT, SUBPARTITION_VALUES.get(1), SUBPARTITION_VALUES.get(2), SUBPARTITION_VALUES.get(3)), DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when 1st subpartition value is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A subpartition value must be specified.", e.getMessage());
}
// Try to update the business object data status without specifying 2nd subpartition value.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUBPARTITION_VALUES.get(0), BLANK_TEXT, SUBPARTITION_VALUES.get(2), SUBPARTITION_VALUES.get(3)), DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when 2nd subpartition value is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A subpartition value must be specified.", e.getMessage());
}
// Try to update the business object data status without specifying 3rd subpartition value.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), BLANK_TEXT, SUBPARTITION_VALUES.get(3)), DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when 3rd subpartition value is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A subpartition value must be specified.", e.getMessage());
}
// Try to update the business object data status without specifying 4th subpartition value.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), SUBPARTITION_VALUES.get(2), BLANK_TEXT), DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
fail("Should throw an IllegalArgumentException when 4th subpartition value is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A subpartition value must be specified.", e.getMessage());
}
// Try to update the business object data status when status is not specified.
try {
businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BLANK_TEXT));
fail("Should throw an IllegalArgumentException when business object status is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object data status must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDataStatusServiceTest method testUpdateBusinessObjectDataStatusMissingOptionalParameters.
@Test
public void testUpdateBusinessObjectDataStatusMissingOptionalParameters() {
// Create and persist a business object data status entity.
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS_2);
// Test if we can retrieve an attribute for the business object data with any allowed number of subpartition values (from 0 to MAX_SUBPARTITIONS).
for (int i = 0; i <= BusinessObjectDataEntity.MAX_SUBPARTITIONS; i++) {
// Build a list of subpartition values.
List<String> subPartitionValues = SUBPARTITION_VALUES.subList(0, i);
// Create and persist a business object data entity.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues, DATA_VERSION, true, BDATA_STATUS);
// Update the business object data status using the relative endpoint.
BusinessObjectDataStatusUpdateResponse response = null;
switch(i) {
case 0:
response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
break;
case 1:
response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(subPartitionValues.get(0)), DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
break;
case 2:
response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(subPartitionValues.get(0), subPartitionValues.get(1)), DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
break;
case 3:
response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(subPartitionValues.get(0), subPartitionValues.get(1), subPartitionValues.get(2)), DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
break;
case 4:
response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
break;
}
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusUpdateResponse(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues, DATA_VERSION), BDATA_STATUS_2, BDATA_STATUS, response);
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDataStatusServiceTest method testUpdateBusinessObjectDataStatus.
@Test
public void testUpdateBusinessObjectDataStatus() {
// Create and persist relative test entities.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS_2);
// Update the business object data status.
BusinessObjectDataStatusUpdateResponse response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusUpdateResponse(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BDATA_STATUS_2, BDATA_STATUS, response);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDataStatusServiceTest method testUpdateBusinessObjectDataStatusUpperCaseParameters.
@Test
public void testUpdateBusinessObjectDataStatusUpperCaseParameters() {
// Create and persist relative test entities.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS.toLowerCase());
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS_2.toLowerCase());
// Update the business object data status using upper case input parameters (except for case-sensitive partition values).
BusinessObjectDataStatusUpdateResponse response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2.toUpperCase()));
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusUpdateResponse(new BusinessObjectDataKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BDATA_STATUS_2.toLowerCase(), BDATA_STATUS.toLowerCase(), response);
}
Aggregations