diff options
author | Edyta Krukowska <edyta.krukowska@nokia.com> | 2020-12-15 13:45:37 +0100 |
---|---|---|
committer | Edyta Krukowska <edyta.krukowska@nokia.com> | 2020-12-17 12:04:05 +0100 |
commit | 26c6238bd7e5a48363b86122b9b40f013ed29f1a (patch) | |
tree | 329736e49b1fca0f9dd54dcc36f5b30f626c3186 /sdc-distribution-ci/src/test | |
parent | 64079b27bdfff509fe610b1d46e09bdf1e43e4c6 (diff) |
Remove old content of CI project and create integration tests
Issue-ID: SDC-3400
Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com>
Change-Id: I1b46858cfae199aefcdeb8dfc14a33f50f4da7d6
Diffstat (limited to 'sdc-distribution-ci/src/test')
2 files changed, 78 insertions, 511 deletions
diff --git a/sdc-distribution-ci/src/test/java/org/onap/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java b/sdc-distribution-ci/src/test/java/org/onap/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java deleted file mode 100644 index 22b1607..0000000 --- a/sdc-distribution-ci/src/test/java/org/onap/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java +++ /dev/null @@ -1,511 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.ci.tests.execute.downloadArtifactUGN; - -import org.junit.Test; - -/** - * - * @author al714h - * US510007 - Story : ASDC Distr Client - Download Artifact - * following test set partially cover the US451327 - Story : API to download the specific artifact, cover the audit message. - */ - -//public class ClientDownloadArtifact extends AttSdcTest{ - public class ClientDownloadArtifact { - -// Logger logger = null; -// -// DistributionUtils distributionUtils = new DistributionUtils(); -// DownloadArtifactDetails downloadArtifactDetails = new DownloadArtifactDetails(); -// Utils utils = new Utils(); -// DbUtils dbUtils = new DbUtils(); -// UserUtils userUtils = new UserUtils(); -// ResourceUtils resourceUtils = new ResourceUtils(); -// ServiceUtils serviceUtils = new ServiceUtils(); -// ArtifactUtils artifactUtils = new ArtifactUtils(); -// private JSONParser jsonParser = new JSONParser(); -// - String serviceBaseVersion = "0.1"; -// -// @Before -// public void before() throws Exception { -// -// distributionUtils.resetInit(); -// dbUtils.cleanAllAudits(); -// } -// @Rule -// public static TestName name = new TestName(); -// -// } -// -// @Rule -// public static TestName name = new TestName(); -// -//// public ClientDownloadArtifact() { -//// super(name, ClientDownloadArtifact.class.getName()); -//// } -// -// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); -//// get default artifact info to upload -// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -//// set artifact info for download -// downloadArtifactDetails.setArtifactName(uploadedResourceArtifactInfo.getArtifactName()); -// String artifactName = downloadArtifactDetails.getArtifactName(); -//// Andrey TODO String resourceArtifactUrl = String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT,); -// -// int numOfResourcArtifacts = 1; -// RestResponse createCertifiedResourceWithArtifacts = resourceUtils.createCertifiedResourceWithArtifacts(resourceDetails, uploadedResourceArtifactInfo, numOfResourcArtifacts); -// -// -// -// try{ -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedResourceArtifactInfo); -// -// // validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// }finally{ -//// delete created resource -// resourceUtils.deleteResource_allVersions(resourceDetails, UserUtils.getAdminDetails()); -// } - -// } - -// send all mandatory headers only - @Test - public void downloadServiceArtifactSuccess() throws Exception{ - -//// ServiceReqDetails serviceDetails = serviceUtils.createDefaultDetailsService(); -// ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); -// Service service = new Service(); -// try{ -//// get default artifact info to upload -// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -// uploadedResourceArtifactInfo.setArtifactType(ArtifactTypeEnum.HEAT.getType()); -// ArtifactDefinition uploadedServiceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -// uploadedServiceArtifactInfo.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); -// -//// set artifact info for download -// downloadArtifactDetails.setArtifactName(uploadedServiceArtifactInfo.getArtifactName()); -// downloadArtifactDetails.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); -// String artifactName = downloadArtifactDetails.getArtifactName(); -// -//// create default resource details -// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); -// -// int numOfResourcArtifacts = 1; -// service = serviceUtils.createCertifiedServiceWithResourceInstanceAndArtifacts(serviceDetails, resourceDetails, uploadedResourceArtifactInfo, uploadedServiceArtifactInfo , numOfResourcArtifacts); -// logger.debug("service version = " + service.getVersion()); -// logger.debug("service distribution status = " + service.getDistributionStatus()); -// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service, UserUtils.getGovernorDetails1()); -// -// int status = changeDistributionStateToApprove.getErrorCode(); -// assertTrue("response code is not 200, returned :" + status, status == 200); -// -// serviceDetails.setVersion(service.getVersion()); -// serviceDetails.setUniqueId(service.getUniqueId()); -// -// String responseString = changeDistributionStateToApprove.getResponse(); -// Gson gson = new Gson(); -// service = gson.fromJson(responseString, Service.class); -// ServiceMetadataDataDefinition serviceMetadataDataDefinition = gson.fromJson(responseString, ServiceMetadataDataDefinition.class); -// service.setDistributionStatus(DistributionStatusEnum.findState(serviceMetadataDataDefinition.getDistributionStatus())); -// DistributionStatusEnum distributionStatus = service.getDistributionStatus(); -// assertNotNull("distribution state is null",distributionStatus.name()); -// assertTrue("the default distribution state is invalid", DistributionStatusEnum.DISTRIBUTION_APPROVED.equals(distributionStatus)); -// -// String serviceArtifactUrl = String.format(Urls.DISTRIBUTION_DOWNLOAD_ARTIFACT,service.getName(), service.getVersion(), artifactName); -// logger.debug("download service artifact url: "+ serviceArtifactUrl+ " serviceName = " + service.getName() + " service version = " + service.getVersion() + "service artifact name = " + artifactName); -// -// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedArtifactInfo); -//// -//// // validate audit message server side -//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -//// String action = "ArtifactDownload"; -//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// }finally{ -//// delete created service -// serviceUtils.deleteService_allVersions(serviceDetails, UserUtils.getAdminDetails()); -// } - -// @Test -// public void downloadServiceArtifactSuccess() throws Exception{ -// -//// ServiceReqDetails serviceDetails = serviceUtils.createDefaultDetailsService(); -// ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); -// Service service = new Service(); -// try{ -//// get default artifact info to upload -// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -// uploadedResourceArtifactInfo.setArtifactType(ArtifactTypeEnum.HEAT.getType()); -// ArtifactDefinition uploadedServiceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -// uploadedServiceArtifactInfo.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); -// -//// set artifact info for download -// downloadArtifactDetails.setArtifactName(uploadedServiceArtifactInfo.getArtifactName()); -// downloadArtifactDetails.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); -// String artifactName = downloadArtifactDetails.getArtifactName(); -// -//// create default resource details -// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); -// -// int numOfResourcArtifacts = 1; -// service = serviceUtils.createCertifiedServiceWithResourceInstanceAndArtifacts(serviceDetails, resourceDetails, uploadedResourceArtifactInfo, uploadedServiceArtifactInfo , numOfResourcArtifacts); -// logger.debug("service version = " + service.getVersion()); -// logger.debug("service distribution status = " + service.getDistributionStatus()); -// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service, UserUtils.getGovernorDetails1()); -// -// int status = changeDistributionStateToApprove.getErrorCode(); -// assertTrue("response code is not 200, returned :" + status, status == 200); -// -// serviceDetails.setVersion(service.getVersion()); -// serviceDetails.setUniqueId(service.getUniqueId()); -// -// String responseString = changeDistributionStateToApprove.getResponse(); -// Gson gson = new Gson(); -// service = gson.fromJson(responseString, Service.class); -// ServiceMetadataDataDefinition serviceMetadataDataDefinition = gson.fromJson(responseString, ServiceMetadataDataDefinition.class); -// service.setDistributionStatus(DistributionStatusEnum.findState(serviceMetadataDataDefinition.getDistributionStatus())); -// DistributionStatusEnum distributionStatus = service.getDistributionStatus(); -// assertNotNull("distribution state is null",distributionStatus.name()); -// assertTrue("the default distribution state is invalid", DistributionStatusEnum.DISTRIBUTION_APPROVED.equals(distributionStatus)); -// -// String serviceArtifactUrl = String.format(Urls.DISTRIBUTION_DOWNLOAD_ARTIFACT,service.getName(), service.getVersion(), artifactName); -// logger.debug("download service artifact url: "+ serviceArtifactUrl+ " serviceName = " + service.getName() + " service version = " + service.getVersion() + "service artifact name = " + artifactName); -// -// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedArtifactInfo); -//// -//// // validate audit message server side -//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -//// String action = "ArtifactDownload"; -//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// }finally{ -//// delete created service -// serviceUtils.deleteService_allVersions(serviceDetails, UserUtils.getAdminDetails()); -// } -// -// } -// -//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers -////// send all headers mandatory and not mandatory -//// @Test -//// public void downloadArtifactSuccessMandatoryAndNotMandatoryHeaders() throws Exception{ -//// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// -//// Map<String, String> headersMap = new HashMap<String,String>(); -//// headersMap.put(HttpHeaderEnum.X_ECOMP_InstanceID.getValue(), "instar_name"); // mandatory -//// headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), "usernamePassword"); // mandatory -//// headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/octet-stream"); // not mandatory -//// headersMap.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(),downloadArtifactDetails.getResourceUUID());// not mandatory -//// Log.debug("headers detailes: "+ headersMap.toString()); -//// -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); -//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse); -//// -////// validate audit message server side -//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -//// String action = "ArtifactDownload"; -//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -//// -//// } -// -// -////---------------------------------Failure scenario-------------------------------------------------------------------------------- -// -//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers -////// missing InstanceID mandatory header -//// @Test -//// public void downloadArtifactMissingInstanceIdHeader() throws Exception, JSONException{ -//// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// -//// Map<String, String> headersMap = new HashMap<String,String>(); -//// headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), "usernamePassword"); // mandatory -//// Log.debug("headers detailes: "+ headersMap.toString()); -//// -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); -//// -//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID.name()); -//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -//// -//// List<String> variables = Arrays.asList(); -//// utils.checkBodyResponseOnError(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID.name(), variables, downloadArtifactRestResponse.getResponse())); -//// -//// } -// -//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers -////// missing Authorization mandatory header -//// @Test -//// public void downloadArtifactMissingAuthorizationHeader() throws Exception, JSONException{ -//// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// -//// Map<String, String> headersMap = new HashMap<String,String>(); -//// headersMap.put(HttpHeaderEnum.X_ECOMP_InstanceID.getValue(), "usernamePassword"); // mandatory -//// Log.debug("headers detailes: "+ headersMap.toString()); -//// -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); -//// -//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS.name()); -//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -//// -//// List<String> variables = Arrays.asList(); -//// utils.checkBodyResponseOnError(ActionStatus.ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS.name(), variables, downloadArtifactRestResponse.getResponse())); -//// -//// } -// -// -//// artifact not found -// @Test -// public void downloadArtifactArtifactNotFound() throws Exception, JSONException{ -// -// downloadArtifactDetails.setArtifactName("artifactNotExist"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// -// } -// -//// service not found -// @Test -// public void downloadArtifactServiceNameNotFound() throws Exception, JSONException{ -// -// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceNotExist/0.1/artifacts/aaa.hh"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -//// TODO Andrey, change desc message -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// -// } -// -// -//// service version not found -// @Test -// public void downloadArtifactServiceVersionNotFound() throws Exception, JSONException{ -// -// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceName/0.888/artifacts/aaa.hh"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -//// TODO Andrey, change desc message -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// -// } -// -//// invalid HTTP method, PUT HTTP method -// @Test -// public void downloadArtifactByPutMethod() throws Exception, JSONException{ -// -// String method = "PUT"; -// -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); -// -// } -// -//// invalid HTTP method, DELETE HTTP method -// @Test -// public void downloadArtifactByDeleteMethod() throws Exception, JSONException{ -// -// String method = "DELETE"; -// downloadArtifactDetails.setArtifactName("artifactNotExist"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// -// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceNotExist/0.1/artifacts/aaa.hh"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -//// TODO Andrey, change desc message -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceName/0.888/artifacts/aaa.hh"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -//// TODO Andrey, change desc message -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List<String> variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); -// downloadArtifactDetails.setArtifactChecksum("invalidChecksum"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -//// TODO -// -//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name()); -//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -//// -//// List<String> variables = Arrays.asList(); -//// utils.checkBodyResponseOnError(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse())); -// -// downloadArtifactDetails.setArtifactChecksum("invalidChecksum"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -//// TODO -// -//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name()); -//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -//// -//// List<String> variables = Arrays.asList(); -//// utils.checkBodyResponseOnError(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse())); -// -// } -// -// -// -// - - } - -} diff --git a/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java new file mode 100644 index 0000000..e4c2241 --- /dev/null +++ b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.test.core.service; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.test.core.config.DistributionClientConfig; +import org.slf4j.Logger; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.verify; + +@Testcontainers +@ExtendWith(MockitoExtension.class) +class ClientInitializerTest { + + + public static final int SUCCESSFUL_INIT_MSG_INDEX = 0; + public static final int SUCCESSFUL_DIST_MSG_INDEX = 3; + @Container + public GenericContainer mockDmaap = new GenericContainer("registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-dmaap:latest") + .withNetworkMode("host"); + + @Container + public GenericContainer mockSdc = new GenericContainer("registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdc:latest") + .dependsOn(mockDmaap) + .withNetworkMode("host"); + @Mock + Logger log; + + @Test + public void shouldRegisterToDmaapAfterClientInitialization() { + //given + DistributionClientConfig clientConfig = new DistributionClientConfig(); + List<ArtifactsValidator> validators = new ArrayList<>(); + DistributionClientImpl client = new DistributionClientImpl(); + ClientNotifyCallback callback = new ClientNotifyCallback(validators, client); + ClientInitializer clientInitializer = new ClientInitializer(clientConfig, callback, client); + final ArgumentCaptor<String> exceptionCaptor = ArgumentCaptor.forClass(String.class); + //when + clientInitializer.log = log; + clientInitializer.initialize(); + verify(log, Mockito.atLeastOnce()).info(exceptionCaptor.capture()); + List<String> allValues = exceptionCaptor.getAllValues(); + //then + assertThat(allValues.get(SUCCESSFUL_INIT_MSG_INDEX)).isEqualTo("distribution client initialized successfuly"); + assertThat(allValues.get(SUCCESSFUL_DIST_MSG_INDEX)).isEqualTo("distribution client started successfuly"); + } + +}
\ No newline at end of file |