RetentionExpirationDestroyerWebClient extends DataBridgeWebClient { public BusinessObjectData destroyBusinessObjectData(BusinessObjectDataKey businessObjectDataKey) throws IOException, JAXBException, URISyntaxException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException { String uriPath = HERD_APP_REST_URI_PREFIX + "/businessObjectData/destroy" + "/namespaces/" + businessObjectDataKey.getNamespace() + "/businessObjectDefinitionNames/" + businessObjectDataKey.getBusinessObjectDefinitionName() + "/businessObjectFormatUsages/" + businessObjectDataKey.getBusinessObjectFormatUsage() + "/businessObjectFormatFileTypes/" + businessObjectDataKey.getBusinessObjectFormatFileType() + "/businessObjectFormatVersions/" + businessObjectDataKey.getBusinessObjectFormatVersion() + "/partitionValues/" + businessObjectDataKey.getPartitionValue() + "/businessObjectDataVersions/" + businessObjectDataKey.getBusinessObjectDataVersion(); URIBuilder uriBuilder = new URIBuilder().setScheme(getUriScheme()).setHost(regServerAccessParamsDto.getRegServerHost()).setPort(regServerAccessParamsDto.getRegServerPort()) .setPath(uriPath); if (CollectionUtils.isNotEmpty(businessObjectDataKey.getSubPartitionValues())) { uriBuilder.setParameter("subPartitionValues", herdStringHelper.join(businessObjectDataKey.getSubPartitionValues(), "|", "\\")); } URI uri = uriBuilder.build(); try (CloseableHttpClient client = httpClientHelper .createHttpClient(regServerAccessParamsDto.isTrustSelfSignedCertificate(), regServerAccessParamsDto.isDisableHostnameVerification())) { HttpPost request = new HttpPost(uri); request.addHeader("Content-Type", DEFAULT_CONTENT_TYPE); request.addHeader("Accepts", DEFAULT_ACCEPT); if (regServerAccessParamsDto.isUseSsl()) { request.addHeader(getAuthorizationHeader()); } LOGGER.info(String.format(" HTTP POST URI: %s", request.getURI().toString())); BusinessObjectData businessObjectData = destroyBusinessObjectData(httpClientOperations.execute(client, request)); LOGGER.info("Successfully destroyed business object data from the registration server."); return businessObjectData; } }  BusinessObjectData destroyBusinessObjectData(BusinessObjectDataKey businessObjectDataKey);  }
@Test public void testDestroyBusinessObjectData() throws Exception { retentionExpirationDestroyerWebClient.getRegServerAccessParamsDto().setUseSsl(false); BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey("test", "test", "test", "test", 0, "test", Collections.singletonList("test"), 0); BusinessObjectData result = retentionExpirationDestroyerWebClient.destroyBusinessObjectData(businessObjectDataKey); assertNotNull(result); }
@Test public void testDestroyBusinessObjectDataException() throws Exception { retentionExpirationDestroyerWebClient.getRegServerAccessParamsDto().setRegServerHost(MockHttpClientOperationsImpl.HOSTNAME_THROW_IO_EXCEPTION); try { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey("test", "test", "test", "test", 0, "test", Collections.singletonList("test"), 0); retentionExpirationDestroyerWebClient.destroyBusinessObjectData(businessObjectDataKey); fail(); } catch (IOException e) { assertEquals("testThrowIoException", e.getMessage()); } }
@Test public void testDestroyBusinessObjectDataUseSsl() throws Exception { retentionExpirationDestroyerWebClient.getRegServerAccessParamsDto().setUseSsl(true); BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey("test", "test", "test", "test", 0, "test", Collections.singletonList("test"), 0); BusinessObjectData result = retentionExpirationDestroyerWebClient.destroyBusinessObjectData(businessObjectDataKey); assertNotNull(result); }