RetentionExpirationExporterWebClient extends DataBridgeWebClient { BusinessObjectDefinition getBusinessObjectDefinition(String namespace, String businessObjectDefinitionName) throws IOException, JAXBException, URISyntaxException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException { LOGGER.info("Retrieving business object definition information from the registration server..."); String uriPathBuilder = HERD_APP_REST_URI_PREFIX + "/businessObjectDefinitions" + "/namespaces/" + namespace + "/businessObjectDefinitionNames/" + businessObjectDefinitionName; URIBuilder uriBuilder = new URIBuilder().setScheme(getUriScheme()).setHost(regServerAccessParamsDto.getRegServerHost()).setPort(regServerAccessParamsDto.getRegServerPort()) .setPath(uriPathBuilder); URI uri = uriBuilder.build(); try (CloseableHttpClient client = httpClientHelper .createHttpClient(regServerAccessParamsDto.isTrustSelfSignedCertificate(), regServerAccessParamsDto.isDisableHostnameVerification())) { HttpGet request = new HttpGet(uri); request.addHeader("Accepts", DEFAULT_ACCEPT); if (regServerAccessParamsDto.isUseSsl()) { request.addHeader(getAuthorizationHeader()); } LOGGER.info(String.format(" HTTP GET URI: %s", request.getURI().toString())); BusinessObjectDefinition businessObjectDefinition = getBusinessObjectDefinition(httpClientOperations.execute(client, request)); LOGGER.info("Successfully retrieved business object definition from the registration server."); return businessObjectDefinition; } }    }
@Test public void testGetBusinessObjectDefinition() throws Exception { retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setUseSsl(false); BusinessObjectDefinition result = retentionExpirationExporterWebClient.getBusinessObjectDefinition(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME); assertNotNull(result); }
@Test public void testGetBusinessObjectDefinitionException() throws Exception { retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setRegServerHost(MockHttpClientOperationsImpl.HOSTNAME_THROW_IO_EXCEPTION); try { retentionExpirationExporterWebClient.getBusinessObjectDefinition(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME); } catch (IOException e) { assertEquals("testThrowIoException", e.getMessage()); } }
@Test public void testGetBusinessObjectDefinitionUseSsl() throws Exception { retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setUseSsl(true); BusinessObjectDefinition result = retentionExpirationExporterWebClient.getBusinessObjectDefinition(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME); assertNotNull(result); }