Search in sources :

Example 1 with BusinessObjectDataStatusUpdateResponse

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);
}
Also used : BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 2 with 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));
}
Also used : BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse)

Example 3 with 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;
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) StringEntity(org.apache.http.entity.StringEntity) Marshaller(javax.xml.bind.Marshaller) StringWriter(java.io.StringWriter) JAXBContext(javax.xml.bind.JAXBContext) BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) HttpPut(org.apache.http.client.methods.HttpPut) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 4 with 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);
    }
}
Also used : BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 5 with BusinessObjectDataStatusUpdateResponse

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);
}
Also used : BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataStatusUpdateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse)17 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)14 Test (org.junit.Test)11 BusinessObjectDataStatusUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest)10 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 StringWriter (java.io.StringWriter)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 HttpPut (org.apache.http.client.methods.HttpPut)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 StringEntity (org.apache.http.entity.StringEntity)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)1 Secured (org.springframework.security.access.annotation.Secured)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1