use of org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse in project herd by FINRAOS.
the class DataBridgeWebClientTest method testUpdateBusinessObjectDataStatus.
/**
* Calls updateBusinessObjectDataStatus() method and makes assertions.
*
* @param useSsl specifies whether to use SSL or not
*
* @throws IOException
* @throws JAXBException
* @throws URISyntaxException
*/
private void testUpdateBusinessObjectDataStatus(List<String> subPartitionValues, boolean useSsl) throws IOException, JAXBException, URISyntaxException {
dataBridgeWebClient.regServerAccessParamsDto.setUseSsl(useSsl);
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
businessObjectDataKey.setSubPartitionValues(subPartitionValues);
String businessObjectDataStatus = "testBusinessObjectDataStatus";
BusinessObjectDataStatusUpdateResponse businessObjectDataStatusUpdateResponse = dataBridgeWebClient.updateBusinessObjectDataStatus(businessObjectDataKey, businessObjectDataStatus);
assertNotNull("businessObjectDataStatusUpdateResponse", businessObjectDataStatusUpdateResponse);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method buildPutBusinessObjectDataStatusResponse.
/**
* Builds a business object data status update response.
*
* @param response the response.
* @param uri the URI of the incoming request.
*
* @throws JAXBException if a JAXB error occurred.
*/
private void buildPutBusinessObjectDataStatusResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
BusinessObjectDataStatusUpdateResponse businessObjectDataStatusUpdateResponse = new BusinessObjectDataStatusUpdateResponse();
response.setEntity(getHttpEntity(businessObjectDataStatusUpdateResponse));
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse 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.BusinessObjectDataStatusUpdateResponse 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.BusinessObjectDataStatusUpdateResponse 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);
}
Aggregations