diff options
59 files changed, 951 insertions, 2054 deletions
diff --git a/features.properties.md b/features.properties.md index 2823c662e..e8dbeccb4 100644 --- a/features.properties.md +++ b/features.properties.md @@ -173,3 +173,7 @@ * FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE Let the user set the order of resource instantiation while using drawing board (new view edit) for a-la-carte instantiation. + +* FLAG_SHOW_ORCHESTRATION_TYPE + enables showing/hiding (true/false) column with orchestration type in Service Model browser. + The types are fetched from aai.
\ No newline at end of file diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml index 78d9af771..21a67695e 100755 --- a/vid-app-common/pom.xml +++ b/vid-app-common/pom.xml @@ -607,6 +607,16 @@ <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> </dependency> + <dependency> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-filter-base</artifactId> + <version>1.5.1</version> + </dependency> + <dependency> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-filter-spring</artifactId> + <version>1.5.1</version> + </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java index 7e96c93cd..159401009 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java @@ -459,7 +459,7 @@ public class AaiClient implements AaiClientInterface { } @Override - public AaiResponse getVNFData(String globalSubscriberId, String serviceType) { + public AaiResponse<AaiGetVnfResponse> getVNFData(String globalSubscriberId, String serviceType) { String payload = "{\"start\": [\"business/customers/customer/" + globalSubscriberId + SERVICE_SUBSCRIPTIONS_PATH + encodePathSegment(serviceType) +"/service-instances\"]," + "\"query\": \"query/vnf-topology-fromServiceInstance\"}"; Response resp = doAaiPut(QUERY_FORMAT_SIMPLE, payload, false); diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java index af5429c28..2a879e295 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java @@ -65,7 +65,7 @@ public interface AaiClientInterface extends ProbeInterface { AaiResponse getInstanceGroupsByCloudRegion(String cloudOwner, String cloudRegionId, String networkFunction); - AaiResponse getVNFData(String globalSubscriberId, String serviceType); + AaiResponse<AaiGetVnfResponse> getVNFData(String globalSubscriberId, String serviceType); AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId); diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java index f2f6ca50a..099f2449b 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java @@ -32,6 +32,7 @@ public class ModelVer { private String distributionStatus; private String resourceVersion; private String modelDescription; + private String orchestrationType; @@ -89,4 +90,12 @@ public class ModelVer { this.modelDescription = modelDescription; } + public String getOrchestrationType() { + return orchestrationType; + } + + @JsonAlias("orchestration-type") + public void setOrchestrationType(String orchestrationType) { + this.orchestrationType = orchestrationType; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java index 034800516..4369c17fc 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java @@ -8,9 +8,9 @@ * 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. @@ -22,7 +22,8 @@ package org.onap.vid.aai.util; import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; -import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY; +import static org.onap.vid.logging.Headers.INVOCATION_ID; +import static org.onap.vid.logging.Headers.PARTNER_NAME; import com.att.eelf.configuration.EELFLogger; import java.io.UnsupportedEncodingException; @@ -30,6 +31,7 @@ import java.net.URI; import java.net.URLEncoder; import java.util.Optional; import java.util.UUID; +import java.util.function.Supplier; import javax.ws.rs.client.Client; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; @@ -41,6 +43,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.aai.ExceptionWithRequestInfo; import org.onap.vid.aai.ResponseWithRequestInfo; import org.onap.vid.aai.exceptions.InvalidPropertyException; +import org.onap.vid.logging.RequestIdHeader; import org.onap.vid.utils.Logging; import org.onap.vid.utils.Unchecked; import org.springframework.beans.factory.annotation.Autowired; @@ -52,305 +55,222 @@ import org.springframework.http.HttpMethod; */ public class AAIRestInterface { - /** The logger. */ - protected EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AAIRestInterface.class); - - protected final EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("aai"); - - /** The client. */ - private Client client = null; - - /** The rest srvr base URL. */ - private String restSrvrBaseURL; - - @Autowired - protected HttpsAuthClient httpsAuthClientFactory; - private final ServletRequestHelper servletRequestHelper; - private final SystemPropertyHelper systemPropertyHelper; - protected final Logging loggingService; - - protected static final String START_STRING = " start"; - protected static final String TRANSACTION_ID_HEADER = "X-TransactionId"; - protected static final String FROM_APP_ID_HEADER = "X-FromAppId"; - protected static final String SUCCESSFUL_API_MESSAGE = " REST api call was successful!"; - protected static final String URL_DECLARATION = ", url="; - - public AAIRestInterface(HttpsAuthClient httpsAuthClientFactory, - ServletRequestHelper servletRequestHelper, - SystemPropertyHelper systemPropertyHelper, - Logging loggingService) { - this.httpsAuthClientFactory = httpsAuthClientFactory; - this.servletRequestHelper = servletRequestHelper; - this.systemPropertyHelper = systemPropertyHelper; - this.loggingService = loggingService; - initRestClient(); - } - - /** - * For testing purpose - */ - AAIRestInterface(Optional<Client> client, - HttpsAuthClient httpsAuthClientFactory, - ServletRequestHelper servletRequestHelper, - SystemPropertyHelper systemPropertyHelper, - Logging loggingService){ - this.httpsAuthClientFactory = httpsAuthClientFactory; - this.servletRequestHelper = servletRequestHelper; - this.systemPropertyHelper = systemPropertyHelper; - this.loggingService = loggingService; - if (client != null && client.isPresent()){ - this.client = client.get(); - } - - } - - /** - * Encode URL. - * - * @param nodeKey the node key - * @return the string - * @throws UnsupportedEncodingException the unsupported encoding exception - */ - public String encodeURL (String nodeKey) throws UnsupportedEncodingException { - return URLEncoder.encode(nodeKey, "UTF-8").replaceAll("\\+", "%20"); - } - - protected void initRestClient() { - initRestClient(false); - } - - - private void initRestClient(boolean propagateExceptions) { - if (client == null) { - try { - client = httpsAuthClientFactory.getClient(HttpClientMode.WITH_KEYSTORE); - } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : " + e.toString()); - if (propagateExceptions) { - ExceptionUtils.rethrow(e); - } - } - } - } - - - - /** - * Sets the rest srvr base URL. - * - * @param baseURL the base URL - */ - public void setRestSrvrBaseURL(String baseURL) - { - if (baseURL == null) { - logger.info(EELFLoggerDelegate.errorLogger, "REST Server base URL cannot be null."); - logger.debug(EELFLoggerDelegate.debugLogger, "REST Server base URL cannot be null."); - } - - restSrvrBaseURL = baseURL; - } - - /** - * Gets the rest srvr base URL. - * - * @return the rest srvr base URL - */ - public String getRestSrvrBaseURL() { - return restSrvrBaseURL; - } - - - /** - * Rest get. - * - * @param fromAppId the from app id - * @param transId the trans id - * @param requestUri the request uri - * @param xml the xml - * @return the string - */ - public ResponseWithRequestInfo RestGet(String fromAppId, String transId, URI requestUri, boolean xml) { - return RestGet(fromAppId, transId, requestUri, xml, false); - } - - public ResponseWithRequestInfo RestGet(String fromAppId, String transId, URI requestUri, boolean xml, boolean propagateExceptions) { - return doRest(fromAppId, transId, requestUri, null, HttpMethod.GET, xml, propagateExceptions); - } - - public ResponseWithRequestInfo doRest(String fromAppId, String transId, URI requestUri, String payload, HttpMethod method, boolean xml, boolean propagateExceptions) { - String url = null; - String methodName = "Rest"+method.name(); - try { - - url = systemPropertyHelper.getFullServicePath(requestUri); - - initRestClient(propagateExceptions); - - logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING); - logger.debug(EELFLoggerDelegate.debugLogger, url + " for the get REST API"); - - loggingService.logRequest(outgoingRequestsLogger, method, url, payload); - - final Response response; - Invocation.Builder requestBuilder = client.target(url) - .request() - .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON) - .header(TRANSACTION_ID_HEADER, transId) - .header(FROM_APP_ID_HEADER, fromAppId) - .header("Content-Type", MediaType.APPLICATION_JSON) - .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId()); - - requestBuilder = systemPropertyHelper.isClientCertEnabled() ? - requestBuilder : authenticateRequest(requestBuilder); - - Invocation restInvocation = StringUtils.isEmpty(payload) ? - requestBuilder.build(method.name()) : - requestBuilder.build(method.name(), Entity.entity(payload, MediaType.APPLICATION_JSON)); - - response = restInvocation.invoke(); - loggingService.logResponse(outgoingRequestsLogger, method, url, response); - - if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { - logger.debug(EELFLoggerDelegate.debugLogger, methodName + SUCCESSFUL_API_MESSAGE); - logger.info(EELFLoggerDelegate.errorLogger, methodName + SUCCESSFUL_API_MESSAGE); - } else { - logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, response)); - } - return new ResponseWithRequestInfo(response, url, method); - } catch (Exception e) { - logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e)); - if (propagateExceptions) { - throw new ExceptionWithRequestInfo(method, defaultIfNull(url, requestUri.toASCIIString()), e); - } else { - return new ResponseWithRequestInfo(null, url, method); - } - } - } - - protected String extractOrGenerateRequestId() { - return servletRequestHelper.extractOrGenerateRequestId(); - } - - - /** - * Delete. - * - * @param sourceID the source ID - * @param transId the trans id - * @param path the path - * @return true, if successful - */ - public boolean Delete(String sourceID, String transId, String path) { - String methodName = "Delete"; - transId += ":" + UUID.randomUUID().toString(); - logger.debug(methodName + START_STRING); - Boolean response = false; - String url = systemPropertyHelper.getFullServicePath(path); - try { - - initRestClient(); - loggingService.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url); - final Response cres = client.target(url) - .request() - .accept(MediaType.APPLICATION_JSON) - .header(TRANSACTION_ID_HEADER, transId) - .header(FROM_APP_ID_HEADER, sourceID) - .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId()) - .delete(); - loggingService.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres); - if (cres.getStatusInfo().equals(Response.Status.NOT_FOUND)) { - logger.debug(EELFLoggerDelegate.debugLogger, "Resource does not exist...: " + cres.getStatus() - + ":" + cres.readEntity(String.class)); - response = false; - } else if (cres.getStatusInfo().equals(Response.Status.OK) || cres.getStatusInfo().equals(Response.Status.NO_CONTENT)) { - logger.debug(EELFLoggerDelegate.debugLogger, "Resource " + url + " deleted"); - logger.info(EELFLoggerDelegate.errorLogger, "Resource " + url + " deleted"); - response = true; - } else { - logger.debug(EELFLoggerDelegate.debugLogger, "Deleting Resource failed: " + cres.getStatus() - + ":" + cres.readEntity(String.class)); - response = false; - } - - } catch (Exception e) { - logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e)); - } - return response; - } - - - /** - * Rest put. - * - * @param fromAppId the from app id - * @param path the path - * @param payload the payload - * @param xml the xml - * @param propagateExceptions - * @return the string - */ - public ResponseWithRequestInfo RestPut(String fromAppId, String path, String payload, boolean xml, boolean propagateExceptions) { - return doRest(fromAppId, UUID.randomUUID().toString(), Unchecked.toURI(path), payload, HttpMethod.PUT, xml, propagateExceptions); - } - - - - /** - * Rest post. - * - * @param fromAppId the from app id - * @param path the path - * @param payload the payload - * @param xml the xml - * @return the string - */ - public Response RestPost(String fromAppId, String path, String payload, boolean xml) { - String methodName = "RestPost"; - String url=systemPropertyHelper.getServiceBasePath(path); - String transId = UUID.randomUUID().toString(); - logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING); - - Response response = null; - try { - initRestClient(); - loggingService.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload); - response = authenticateRequest(client.target(url) - .request() - .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON) - .header(TRANSACTION_ID_HEADER, transId) - .header(FROM_APP_ID_HEADER, fromAppId)) - .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId()) - .post(Entity.entity(payload, MediaType.APPLICATION_JSON)); - loggingService.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, response); - - if (response.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) { - logger.info(EELFLoggerDelegate.errorLogger, getValidResponseLogMessage(methodName)); - logger.debug(EELFLoggerDelegate.debugLogger, getValidResponseLogMessage(methodName)); - } else { - logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, response)); - } - } catch (Exception e) { - logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e)); - } - return response; - } - - protected String getFailedResponseLogMessage(String path, String methodName, Exception e) { - return methodName + URL_DECLARATION + path + ", Exception: " + e.toString(); - } - - protected String getValidResponseLogMessage(String methodName) { - return methodName + URL_DECLARATION; - } - - protected String getInvalidResponseLogMessage(String path, String methodName, Response cres) { - return methodName + " with status=" + cres.getStatus() + URL_DECLARATION + path; - } - - private Invocation.Builder authenticateRequest(Invocation.Builder requestBuilder) throws InvalidPropertyException, UnsupportedEncodingException { - return requestBuilder - .header("Authorization", "Basic " + systemPropertyHelper.getEncodedCredentials()); - } + /** The logger. */ + protected EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AAIRestInterface.class); + + protected final EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("aai"); + + /** The client. */ + private Client client = null; + + /** The rest srvr base URL. */ + private String restSrvrBaseURL; + + @Autowired + protected HttpsAuthClient httpsAuthClientFactory; + private final ServletRequestHelper servletRequestHelper; + private final SystemPropertyHelper systemPropertyHelper; + protected final Logging loggingService; + + protected static final String START_STRING = " start"; + protected static final String TRANSACTION_ID_HEADER = "X-TransactionId"; + protected static final String FROM_APP_ID_HEADER = "X-FromAppId"; + protected static final String SUCCESSFUL_API_MESSAGE = " REST api call was successful!"; + protected static final String URL_DECLARATION = ", url="; + + public AAIRestInterface(HttpsAuthClient httpsAuthClientFactory, + ServletRequestHelper servletRequestHelper, + SystemPropertyHelper systemPropertyHelper, + Logging loggingService) { + this.httpsAuthClientFactory = httpsAuthClientFactory; + this.servletRequestHelper = servletRequestHelper; + this.systemPropertyHelper = systemPropertyHelper; + this.loggingService = loggingService; + initRestClient(); + } + + /** + * For testing purpose + */ + AAIRestInterface(Optional<Client> client, + HttpsAuthClient httpsAuthClientFactory, + ServletRequestHelper servletRequestHelper, + SystemPropertyHelper systemPropertyHelper, + Logging loggingService){ + this.httpsAuthClientFactory = httpsAuthClientFactory; + this.servletRequestHelper = servletRequestHelper; + this.systemPropertyHelper = systemPropertyHelper; + this.loggingService = loggingService; + if (client != null && client.isPresent()){ + this.client = client.get(); + } + + } + + /** + * Encode URL. + * + * @param nodeKey the node key + * @return the string + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + public String encodeURL (String nodeKey) throws UnsupportedEncodingException { + return URLEncoder.encode(nodeKey, "UTF-8").replaceAll("\\+", "%20"); + } + + protected void initRestClient() { + initRestClient(false); + } + + + private void initRestClient(boolean propagateExceptions) { + if (client == null) { + try { + client = httpsAuthClientFactory.getClient(HttpClientMode.WITH_KEYSTORE); + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : " + e.toString()); + if (propagateExceptions) { + ExceptionUtils.rethrow(e); + } + } + } + } + + + + /** + * Sets the rest srvr base URL. + * + * @param baseURL the base URL + */ + public void setRestSrvrBaseURL(String baseURL) + { + if (baseURL == null) { + logger.info(EELFLoggerDelegate.errorLogger, "REST Server base URL cannot be null."); + logger.debug(EELFLoggerDelegate.debugLogger, "REST Server base URL cannot be null."); + } + + restSrvrBaseURL = baseURL; + } + + /** + * Gets the rest srvr base URL. + * + * @return the rest srvr base URL + */ + public String getRestSrvrBaseURL() { + return restSrvrBaseURL; + } + + + public ResponseWithRequestInfo RestGet(String fromAppId, String transId, URI requestUri, boolean xml) { + return RestGet(fromAppId, transId, requestUri, xml, false); + } + + public ResponseWithRequestInfo RestGet(String fromAppId, String transId, URI requestUri, boolean xml, boolean propagateExceptions) { + return doRest(fromAppId, transId, requestUri, null, HttpMethod.GET, xml, propagateExceptions); + } + + public ResponseWithRequestInfo doRest(String fromAppId, String transId, URI requestUri, String payload, HttpMethod method, boolean xml, boolean propagateExceptions) { + return doRest(fromAppId, transId, ()->systemPropertyHelper.getFullServicePath(requestUri), payload, method, xml, propagateExceptions); + } + + + public ResponseWithRequestInfo doRest(String fromAppId, String transId, Supplier<String> urlSupplier, String payload, HttpMethod method, boolean xml, boolean propagateExceptions) { + String url = null; + String methodName = "Rest"+method.name(); + try { + + url = urlSupplier.get(); + + initRestClient(propagateExceptions); + + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING); + logger.debug(EELFLoggerDelegate.debugLogger, url + " for the get REST API"); + + loggingService.logRequest(outgoingRequestsLogger, method, url, payload); + + final Response response; + + String requestId = extractOrGenerateRequestId(); + + Invocation.Builder requestBuilder = client.target(url) + .request() + .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON) + .header(PARTNER_NAME.getHeaderName(), PARTNER_NAME.getHeaderValue()) + .header(TRANSACTION_ID_HEADER, transId) + .header(FROM_APP_ID_HEADER, fromAppId) + .header("Content-Type", MediaType.APPLICATION_JSON) + .header(RequestIdHeader.ONAP_ID.getHeaderName(), requestId) + .header(RequestIdHeader.ECOMP_ID.getHeaderName(), requestId) + .header(INVOCATION_ID.getHeaderName(), INVOCATION_ID.getHeaderValue()) + ; + + requestBuilder = systemPropertyHelper.isClientCertEnabled() ? + requestBuilder : authenticateRequest(requestBuilder); + + Invocation restInvocation = StringUtils.isEmpty(payload) ? + requestBuilder.build(method.name()) : + requestBuilder.build(method.name(), Entity.entity(payload, MediaType.APPLICATION_JSON)); + + response = restInvocation.invoke(); + loggingService.logResponse(outgoingRequestsLogger, method, url, response); + + if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { + logger.debug(EELFLoggerDelegate.debugLogger, methodName + SUCCESSFUL_API_MESSAGE); + logger.info(EELFLoggerDelegate.errorLogger, methodName + SUCCESSFUL_API_MESSAGE); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, response)); + } + return new ResponseWithRequestInfo(response, url, method); + } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e)); + if (propagateExceptions) { + throw new ExceptionWithRequestInfo(method, defaultIfNull(url, ""), e); + } else { + return new ResponseWithRequestInfo(null, url, method); + } + } + } + + protected String extractOrGenerateRequestId() { + return servletRequestHelper.extractOrGenerateRequestId(); + } + + + public ResponseWithRequestInfo RestPut(String fromAppId, String path, String payload, boolean xml, boolean propagateExceptions) { + return doRest(fromAppId, UUID.randomUUID().toString(), Unchecked.toURI(path), payload, HttpMethod.PUT, xml, propagateExceptions); + } + + + public Response RestPost(String fromAppId, String path, String payload, boolean xml) { + ResponseWithRequestInfo response = doRest( + fromAppId, + UUID.randomUUID().toString(), + ()->systemPropertyHelper.getServiceBasePath(path), + payload, + HttpMethod.POST, + xml, + false); + return response.getResponse(); + } + + protected String getFailedResponseLogMessage(String path, String methodName, Exception e) { + return methodName + URL_DECLARATION + path + ", Exception: " + e.toString(); + } + + protected String getValidResponseLogMessage(String methodName) { + return methodName + URL_DECLARATION; + } + + protected String getInvalidResponseLogMessage(String path, String methodName, Response cres) { + return methodName + " with status=" + cres.getStatus() + URL_DECLARATION + path; + } + + private Invocation.Builder authenticateRequest(Invocation.Builder requestBuilder) throws InvalidPropertyException, UnsupportedEncodingException { + return requestBuilder + .header("Authorization", "Basic " + systemPropertyHelper.getEncodedCredentials()); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java index ca151a731..0d37fb39e 100644 --- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java @@ -23,88 +23,59 @@ package org.onap.vid.asdc.beans; import java.util.Collection; import java.util.UUID; -/** - * The Class Service. - */ public class Service { - /** - * The Enum DistributionStatus. - */ public enum DistributionStatus { - /** The distribution not approved. */ DISTRIBUTION_NOT_APPROVED, - /** The distribution approved. */ DISTRIBUTION_APPROVED, - /** The distributed. */ DISTRIBUTED, - /** The distribution rejected. */ DISTRIBUTION_REJECTED, - /** The destributed for tenant isolation. */ DISTRIBUTION_COMPLETE_OK } - /** - * The Enum LifecycleState. - */ public enum LifecycleState { - /** The not certified checkout. */ NOT_CERTIFIED_CHECKOUT, - /** The not certified checkin. */ NOT_CERTIFIED_CHECKIN, - /** The ready for certification. */ READY_FOR_CERTIFICATION, - /** The certification in progress. */ CERTIFICATION_IN_PROGRESS, - /** The certified. */ CERTIFIED } - /** The uuid. */ private String uuid; - /** The invariant UUID. */ private String invariantUUID; - /** The name. */ private String name; - /** The version. */ private String version; - /** The tosca model URL. */ private String toscaModelURL; - /** The category. */ private String category; - /** The lifecycle state. */ private Service.LifecycleState lifecycleState; - /** The last updater user uid. */ private String lastUpdaterUserId; - /** The last updater full name. */ private String lastUpdaterFullName; - /** The distribution status. */ private String distributionStatus; - /** The artifacts. */ private Collection<Artifact> artifacts; - /** The resources. */ private Collection<SubResource> resources; + + private String orchestrationType; public static class ServiceBuilder { @@ -118,6 +89,7 @@ public class Service { private String distributionStatus; private Collection<Artifact> artifacts; private Collection<SubResource> resources; + private String orchestrationType; public ServiceBuilder setUuid(String uuid) { this.uuid = uuid; @@ -169,253 +141,131 @@ public class Service { return this; } + public ServiceBuilder setOrchestrationType(String orchestrationType) { + this.orchestrationType = orchestrationType; + return this; + } + public Service build() { return new Service(this); } } - /** - * Gets the uuid. - * - * @return the uuid - */ public String getUuid() { return uuid; } - /** - * Gets the invariant UUID. - * - * @return the invariant UUID - */ public String getInvariantUUID() { return invariantUUID; } - /** - * Gets the name. - * - * @return the name - */ public String getName() { return name; } - /** - * Gets the version. - * - * @return the version - */ public String getVersion() { return version; } - /** - * Gets the tosca model URL. - * - * @return the tosca model URL - */ public String getToscaModelURL() { return toscaModelURL; } - /** - * Gets the category. - * - * @return the category - */ public String getCategory() { return category; } - /** - * Gets the lifecycle state. - * - * @return the lifecycle state - */ public Service.LifecycleState getLifecycleState() { return lifecycleState; } - /** - * Gets the last updater user uid. - * - * @return the last updater user uid - */ public String getLastUpdaterUserId() { return lastUpdaterUserId; } - /** - * Gets the last updater full name. - * - * @return the last updater full name - */ public String getLastUpdaterFullName() { return lastUpdaterFullName; } - /** - * Gets the distribution status. - * - * @return the distribution status - */ public String getDistributionStatus() { return distributionStatus; } - /** - * Gets the artifacts. - * - * @return the artifacts - */ public Collection<Artifact> getArtifacts() { return artifacts; } - /** - * Gets the resources. - * - * @return the resources - */ public Collection<SubResource> getResources() { return resources; } - /** - * Sets the uuid. - * - * @param uuid the new uuid - */ + public String getOrchestrationType() { + return orchestrationType; + } + public void setUuid(String uuid) { this.uuid = uuid; } - /** - * Sets the invariant UUID. - * - * @param invariantUUID the new invariant UUID - */ public void setInvariantUUID(String invariantUUID) { this.invariantUUID = invariantUUID; } - /** - * Sets the name. - * - * @param name the new name - */ public void setName(String name) { this.name = name; } - /** - * Sets the version. - * - * @param version the new version - */ public void setVersion(String version) { this.version = version; } - /** - * Sets the tosca model URL. - * - * @param toscaModelURL the new tosca model URL - */ public void setToscaModelURL(String toscaModelURL) { this.toscaModelURL = toscaModelURL; } - /** - * Sets the category. - * - * @param category the new category - */ public void setCategory(String category) { this.category = category; } - /** - * Sets the lifecycle state. - * - * @param lifecycleState the new lifecycle state - */ public void setLifecycleState(Service.LifecycleState lifecycleState) { this.lifecycleState = lifecycleState; } - /** - * Sets the last updater user uid. - * - * @param lastUpdaterUserId the new last updater user uid - */ public void set(String lastUpdaterUserId) { this.lastUpdaterUserId = lastUpdaterUserId; } - /** - * Sets the last updater full name. - * - * @param lastUpdaterFullName the new last updater full name - */ public void setLastUpdaterFullName(String lastUpdaterFullName) { this.lastUpdaterFullName = lastUpdaterFullName; } - /** - * Sets the distribution status. - * - * @param distributionStatus the new distribution status - */ public void setDistributionStatus(String distributionStatus) { this.distributionStatus = distributionStatus; } - /** - * Sets the artifacts. - * - * @param artifacts the new artifacts - */ public void setArtifacts(Collection<Artifact> artifacts) { this.artifacts = artifacts; } - /** - * Sets the resources. - * - * @param resources the new resources - */ public void setResources(Collection<SubResource> resources) { this.resources = resources; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ + public void setOrchestrationType(String orchestrationType) { + this.orchestrationType = orchestrationType; + } + @Override public String toString() { return uuid; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ @Override public int hashCode() { return UUID.fromString(getUuid()).hashCode(); } - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ @Override public boolean equals(Object o) { if (o == this) @@ -442,5 +292,6 @@ public class Service { this.distributionStatus = serviceBuilder.distributionStatus; this.artifacts = serviceBuilder.artifacts; this.resources = serviceBuilder.resources; + this.orchestrationType = serviceBuilder.orchestrationType; } } diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java index 9e139a02a..96be59123 100644 --- a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java @@ -29,6 +29,7 @@ import static org.onap.vid.client.SyncRestClientInterface.HEADERS.AUTHORIZATION; import static org.onap.vid.client.SyncRestClientInterface.HEADERS.CONTENT_TYPE; import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID; import static org.onap.vid.client.UnirestPatchKt.extractRawAsString; +import static org.onap.vid.logging.Headers.PARTNER_NAME; import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY; import com.att.eelf.configuration.EELFLogger; @@ -152,6 +153,7 @@ public class SdcRestClient implements AsdcClient { private Map<String, String> prepareHeaders(String auth, String contentType) { return ImmutableMap.of( X_ECOMP_INSTANCE_ID, SystemProperties.getProperty(APP_DISPLAY_NAME), + PARTNER_NAME.getHeaderName(), PARTNER_NAME.getHeaderValue(), AUTHORIZATION, auth, REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId(), CONTENT_TYPE, contentType diff --git a/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java b/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java index 3c061986c..5607018b0 100644 --- a/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java @@ -21,14 +21,11 @@ package org.onap.vid.client; -import org.glassfish.jersey.client.ClientConfig; -import org.glassfish.jersey.client.ClientProperties; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; - import javax.servlet.ServletContext; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; /** * General HTTP client. @@ -51,10 +48,8 @@ public class HttpBasicClient{ */ public static Client getClient() { - ClientConfig config = new ClientConfig(); - config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); - - return ClientBuilder.newClient(config) - .register(org.onap.vid.aai.util.CustomJacksonJaxBJsonProvider.class); + return ClientBuilder + .newClient() + .register(org.onap.vid.aai.util.CustomJacksonJaxBJsonProvider.class); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java index b7ff82afe..928e19357 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java @@ -20,6 +20,8 @@ package org.onap.vid.controller; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.File; import java.io.IOException; import java.util.List; @@ -63,7 +65,7 @@ public class LoggerController extends RestrictedBaseController { this.logfilePathCreator = logfilePathCreator; } - @GetMapping(value = "/{loggerName:audit|error|metrics}") + @GetMapping(value = "/{loggerName:audit|audit2019|error|metrics}") public String getLog(@PathVariable String loggerName, HttpServletRequest request, @RequestParam(value="limit", defaultValue = "5000") Integer limit) throws IOException { @@ -74,7 +76,7 @@ public class LoggerController extends RestrictedBaseController { } String logfilePath = logfilePathCreator.getLogfilePath(loggerName); - try (final ReversedLinesFileReader reader = new ReversedLinesFileReader(new File(logfilePath))) { + try (final ReversedLinesFileReader reader = new ReversedLinesFileReader(new File(logfilePath), UTF_8)) { Supplier<String> reverseLinesSupplier = () -> { try { return reader.readLine(); diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java index 5b05caa7a..4e7a77cd3 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java @@ -30,6 +30,7 @@ import org.onap.vid.mso.MsoBusinessLogic; import org.onap.vid.mso.MsoBusinessLogicImpl; import org.onap.vid.mso.MsoInterface; import org.onap.vid.mso.MsoProperties; +import org.onap.vid.mso.RestMsoImplementation; import org.onap.vid.mso.rest.MsoRestClientNew; import org.onap.vid.services.CloudOwnerService; import org.onap.vid.services.CloudOwnerServiceImpl; @@ -49,14 +50,23 @@ public class MsoConfig { } @Bean - public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, - HttpsAuthClient httpsAuthClient, + public MsoRestClientNew msoRestClientNew(ObjectMapper unirestObjectMapper, SystemPropertiesWrapper systemPropertiesWrapper, Logging loggingService){ // Satisfy both interfaces -- MsoInterface and RestMsoImplementation return new MsoRestClientNew( new SyncRestClient(unirestObjectMapper, loggingService), SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL), + systemPropertiesWrapper + ); + } + + @Bean + public RestMsoImplementation restMsoImplementation(HttpsAuthClient httpsAuthClient, + SystemPropertiesWrapper systemPropertiesWrapper, + Logging loggingService){ + // Satisfy both interfaces -- MsoInterface and RestMsoImplementation + return new RestMsoImplementation( httpsAuthClient, systemPropertiesWrapper, loggingService diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java index 535c97ce7..da66e8951 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java @@ -38,7 +38,6 @@ import org.onap.vid.mso.MsoResponseWrapper; import org.onap.vid.mso.MsoResponseWrapper2; import org.onap.vid.mso.RestMsoImplementation; import org.onap.vid.mso.RestObject; -import org.onap.vid.mso.rest.MsoRestClientNew; import org.onap.vid.mso.rest.Request; import org.onap.vid.mso.rest.RequestDetails; import org.onap.vid.mso.rest.RequestDetailsWrapper; @@ -90,7 +89,7 @@ public class MsoController extends RestrictedBaseController { private final CloudOwnerService cloudOwnerService; @Autowired - public MsoController(MsoBusinessLogic msoBusinessLogic, MsoRestClientNew msoClientInterface, CloudOwnerService cloudOwnerService) { + public MsoController(MsoBusinessLogic msoBusinessLogic, RestMsoImplementation msoClientInterface, CloudOwnerService cloudOwnerService) { this.msoBusinessLogic = msoBusinessLogic; this.restMso = msoClientInterface; this.cloudOwnerService = cloudOwnerService; diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt index ac5c2751c..df97f89f8 100644 --- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt +++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt @@ -427,14 +427,17 @@ abstract class ResourceCommand( protected fun pushChildrenJobsToBroker(children:Collection<BaseResource>, dataForChild: Map<String, Any>, jobType: JobType?=null): List<String> { - var counter = 0; - return children - .map {Pair(it, counter++)} + return setPositionWhereIsMissing(children) .map { jobAdapter.createChildJob(jobType ?: it.first.jobType, it.first, sharedData, dataForChild, it.second) } .map { jobsBrokerService.add(it) } .map { it.toString() } } + protected fun setPositionWhereIsMissing(children: Collection<BaseResource>): List<Pair<BaseResource, Int>> { + var orderingPosition = children.map{ defaultIfNull(it.position, 0) }.max() ?: 0 + return children + .map {Pair(it, it.position ?: ++orderingPosition)} + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt b/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt index a0bbceea1..e9f83ef22 100644 --- a/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt +++ b/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt @@ -4,18 +4,35 @@ package org.onap.vid.logging import org.onap.portalsdk.core.util.SystemProperties import org.onap.vid.logging.RequestIdHeader.* +import java.util.* import javax.servlet.http.HttpServletRequest -enum class RequestIdHeader(val headerName: String) { +interface Header { + val headerName: String + fun stringEquals(header: String): Boolean = headerName.equals(header, true) +} + +abstract class NamedHeader(override val headerName: String) : Header { + abstract fun getHeaderValue(): String +} + +@JvmField +val PARTNER_NAME = object : NamedHeader("X-ONAP-PartnerName") { + override fun getHeaderValue() = "VID.VID" +} + +@JvmField +val INVOCATION_ID = object : NamedHeader("X-InvocationID") { + override fun getHeaderValue() = UUID.randomUUID().toString() +} +enum class RequestIdHeader(override val headerName: String) : Header { ONAP_ID("X-ONAP-RequestID"), REQUEST_ID("X-RequestID"), TRANSACTION_ID("X-TransactionID"), ECOMP_ID(SystemProperties.ECOMP_REQUEST_ID), ; - fun stringEquals(header: String) = headerName.equals(header, true) - fun getHeaderValue(request: HttpServletRequest): String? = request.getHeader(headerName) } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java index 3d980dce8..8f9b98a55 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java @@ -30,6 +30,7 @@ import static org.onap.vid.controller.MsoController.REQUEST_TYPE; import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID; import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID; import static org.onap.vid.controller.MsoController.WORKFLOW_ID; +import static org.onap.vid.logging.Headers.PARTNER_NAME; import static org.onap.vid.mso.MsoProperties.MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS; import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE; import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE; @@ -230,7 +231,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { UUID requestId = UUID.randomUUID(); extraHeaders.put("X-ONAP-RequestID",requestId.toString()); - extraHeaders.put("X-ONAP-PartnerName","VID"); + extraHeaders.put(PARTNER_NAME.getHeaderName(), PARTNER_NAME.getHeaderValue()); extraHeaders.put("X-RequestorID",userId); return msoClientInterface.invokeWorkflow(request,final_endpoint,extraHeaders); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java index d1cb3a37b..a16b44925 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java @@ -21,14 +21,13 @@ package org.onap.vid.mso; import io.joshworks.restclient.http.HttpResponse; +import java.util.Map; import org.onap.vid.aai.HttpResponseWithRequestInfo; import org.onap.vid.changeManagement.RequestDetailsWrapper; -import org.onap.vid.model.SOWorkflowList; import org.onap.vid.changeManagement.WorkflowRequestDetail; +import org.onap.vid.model.SOWorkflowList; import org.onap.vid.mso.rest.RequestDetails; -import java.util.Map; - /** * Created by pickjonathan on 21/06/2017. */ @@ -124,6 +123,5 @@ public interface MsoInterface { <T> HttpResponse<T> post(String path, RequestDetailsWrapper<?> requestDetailsWrapper, Class<T> responseClass); - <T> HttpResponse<T> post(String path, RequestDetails requestDetails, Class<T> responseClass); } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java index ee1eb0429..91b288998 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java @@ -20,6 +20,8 @@ package org.onap.vid.mso; +import static org.onap.vid.logging.Headers.INVOCATION_ID; +import static org.onap.vid.logging.Headers.PARTNER_NAME; import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY; import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY; import static org.onap.vid.utils.Logging.getMethodCallerName; @@ -36,15 +38,12 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.Response; import org.apache.commons.codec.binary.Base64; -import org.apache.http.HttpException; import org.eclipse.jetty.util.security.Password; +import org.glassfish.jersey.client.ClientProperties; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.vid.aai.ExceptionWithRequestInfo; import org.onap.vid.aai.util.HttpClientMode; import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.client.HttpBasicClient; -import org.onap.vid.exceptions.GenericUncheckedException; -import org.onap.vid.mso.rest.RestInterface; import org.onap.vid.utils.Logging; import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.beans.factory.annotation.Autowired; @@ -53,7 +52,7 @@ import org.springframework.http.HttpMethod; /** * Created by pickjonathan on 26/06/2017. */ -public class RestMsoImplementation implements RestInterface { +public class RestMsoImplementation { /** @@ -85,7 +84,7 @@ public class RestMsoImplementation implements RestInterface { */ @Autowired - protected RestMsoImplementation(HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemProperties, Logging loggingService){ + public RestMsoImplementation(HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemProperties, Logging loggingService){ this.httpsAuthClient=httpsAuthClient; this.systemProperties = systemProperties; this.loggingService = loggingService; @@ -108,12 +107,12 @@ public class RestMsoImplementation implements RestInterface { MultivaluedHashMap<String, Object> commonHeaders = new MultivaluedHashMap(); commonHeaders.put("Authorization", Collections.singletonList(("Basic " + authStringEnc))); - commonHeaders.put("X-ONAP-PartnerName", Collections.singletonList("VID")); + commonHeaders.put(PARTNER_NAME.getHeaderName(), Collections.singletonList(PARTNER_NAME.getHeaderValue())); String requestIdValue = Logging.extractOrGenerateRequestId(); commonHeaders.put(REQUEST_ID_HEADER_KEY, Collections.singletonList(requestIdValue)); commonHeaders.put(ONAP_REQUEST_ID_HEADER_KEY, Collections.singletonList(requestIdValue)); - + commonHeaders.put(INVOCATION_ID.getHeaderName(), Collections.singletonList(INVOCATION_ID.getHeaderValue())); boolean useSsl = true; if ( (mso_url != null) && ( !(mso_url.isEmpty()) ) ) { @@ -136,52 +135,6 @@ public class RestMsoImplementation implements RestInterface { return commonHeaders; } - public <T> RestObjectWithRequestInfo<T> Get(T t, String path, RestObject<T> restObject, boolean warpException) { - String methodName = "Get"; - - logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_LOG); - - String url = null; - String rawData = null; - Integer status = null; - - try { - restObject.set(t); - url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; - - MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - loggingService.logRequest(outgoingRequestsLogger, HttpMethod.GET, url); - final Response cres = client.target(url) - .request() - .accept(APPLICATION_JSON) - .headers(commonHeaders) - .get(); - loggingService.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres); - - cres.bufferEntity(); - status = cres.getStatus(); - rawData = cres.readEntity(String.class); - - restObject.setStatusCode(status); - - if (status == 200 || status == 202) { - t = (T) cres.readEntity(t.getClass()); - restObject.set(t); - logger.debug(EELFLoggerDelegate.debugLogger, methodName + REST_API_SUCCESSFULL_LOG); - - } else { - throw new GenericUncheckedException(new HttpException(methodName + WITH_STATUS + status + " (200 or 202 expected), url= " + url)); - } - - logger.debug(EELFLoggerDelegate.debugLogger, methodName + " received status=" + status); - - return new RestObjectWithRequestInfo<>(HttpMethod.GET, url, restObject, status, rawData); - } catch (RuntimeException e) { - throw warpException ? new ExceptionWithRequestInfo(HttpMethod.GET, url, rawData, status, e) : e; - } - } - - @Override public <T> RestObject<T> GetForObject(String path, Class<T> clazz) { final String methodName = getMethodName(); logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {})", getMethodCallerName(), methodName, path, clazz); @@ -211,80 +164,11 @@ public class RestMsoImplementation implements RestInterface { return restObject; } - @Override - public <T> void Delete(T t, Object r, String path, RestObject<T> restObject) { - - String methodName = "Delete"; - String url=""; - Response cres; - - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + START_LOG); - - try { - MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - - url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; - loggingService.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r); - cres = client.target(url) - .request() - - .accept(APPLICATION_JSON) - .headers(commonHeaders) - //.entity(r) - .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)) - .invoke(); - loggingService.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres); - int status = cres.getStatus(); - restObject.setStatusCode (status); - - if (status == 404) { // resource not found - String msg = "Resource does not exist...: " + cres.getStatus(); - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + msg); - } else if (status == 200 || status == 204){ - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + "Resource " + url + " deleted"); - } else if (status == 202) { - String msg = "Delete in progress: " + status; - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + msg); - } - else { - String msg = "Deleting Resource failed: " + status; - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + msg); - } - - try { - t = (T) cres.readEntity(t.getClass()); - restObject.set(t); - } - catch ( Exception e ) { - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + NO_RESPONSE_ENTITY_LOG - + e.getMessage()); - throw e; - } - - } - catch (Exception e) - { - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + WITH_URL_LOG +url+ EXCEPTION_LOG + e.toString()); - throw e; - } - } - public <T> RestObject<T> PostForObject(Object requestDetails, String path, Class<T> clazz) { logger.debug(EELFLoggerDelegate.debugLogger, REST_MSG_TEMPLATE, getMethodCallerName(), getMethodName(), requestDetails, path, clazz); return restCall(HttpMethod.POST, clazz, requestDetails, path); } - public <T> RestObject<T> DeleteForObject(Object requestDetails, String path, Class<T> clazz) { - logger.debug(EELFLoggerDelegate.debugLogger, REST_MSG_TEMPLATE, getMethodCallerName(), getMethodName(), requestDetails, path, clazz); - return restCall(HttpMethod.DELETE, clazz, requestDetails, path); - } - - @Override - public void Post(String t, Object r, String path, RestObject<String> restObject) { - logger.debug(EELFLoggerDelegate.debugLogger, REST_MSG_TEMPLATE, getMethodCallerName(), getMethodName(), t.getClass(), r, path); - restObject.copyFrom(restCall(HttpMethod.POST, String.class, r, path)); - } - public Invocation.Builder prepareClient(String path, String methodName) { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); @@ -320,7 +204,9 @@ public class RestMsoImplementation implements RestInterface { final Invocation.Builder restBuilder = client.target(url) .request() .accept(APPLICATION_JSON) - .headers(commonHeaders); + .headers(commonHeaders) + .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true) + ; Invocation restInvocation = payload==null ? restBuilder.build(httpMethod.name()) : @@ -364,56 +250,4 @@ public class RestMsoImplementation implements RestInterface { return restObject; } - @Override - public <T> void Put(T t, org.onap.vid.changeManagement.RequestDetailsWrapper r, String path, RestObject<T> restObject) { - - String methodName = "Put"; - String url=""; - - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + START_LOG); - - try { - - MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - - url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; - loggingService.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r); - // Change the content length - final Response cres = client.target(url) - .request() - .accept(APPLICATION_JSON) - .headers(commonHeaders) - //.header("content-length", 201) - .put(Entity.entity(r, MediaType.APPLICATION_JSON)); - - loggingService.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, cres); - - try { - t = (T) cres.readEntity(t.getClass()); - restObject.set(t); - } - catch ( Exception e ) { - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + NO_RESPONSE_ENTITY_LOG - + e.getMessage()); - throw e; - } - - int status = cres.getStatus(); - restObject.setStatusCode (status); - - if ( status >= 200 && status <= 299 ) { - logger.info(EELFLoggerDelegate.errorLogger, "<== " + methodName + REST_API_SUCCESSFULL_LOG); - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + REST_API_SUCCESSFULL_LOG); - - } else { - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + WITH_STATUS +status+ URL_LOG +url); - } - - } catch (Exception e) - { - logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + WITH_URL_LOG +url+ EXCEPTION_LOG + e.toString()); - throw e; - - } - } } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java index b2ccde93b..5e19dad46 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java @@ -20,6 +20,7 @@ */ package org.onap.vid.mso.rest; +import static org.onap.vid.logging.Headers.PARTNER_NAME; import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY; import com.google.common.collect.ImmutableMap; @@ -38,11 +39,11 @@ import org.eclipse.jetty.util.security.Password; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.HttpResponseWithRequestInfo; -import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.changeManagement.MsoRequestDetails; import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.changeManagement.WorkflowRequestDetail; import org.onap.vid.client.SyncRestClient; +import org.onap.vid.logging.Headers; import org.onap.vid.model.RequestReferencesContainer; import org.onap.vid.model.SOWorkflowList; import org.onap.vid.mso.MsoInterface; @@ -50,7 +51,6 @@ import org.onap.vid.mso.MsoProperties; import org.onap.vid.mso.MsoResponseWrapper; import org.onap.vid.mso.MsoResponseWrapperInterface; import org.onap.vid.mso.MsoUtil; -import org.onap.vid.mso.RestMsoImplementation; import org.onap.vid.mso.RestObject; import org.onap.vid.utils.Logging; import org.onap.vid.utils.SystemPropertiesWrapper; @@ -60,27 +60,28 @@ import org.springframework.http.HttpMethod; /** * Created by pickjonathan on 21/06/2017. */ -public class MsoRestClientNew extends RestMsoImplementation implements MsoInterface { +public class MsoRestClientNew implements MsoInterface { /** * The Constant dateFormat. */ public static final String X_FROM_APP_ID = "X-FromAppId"; - public static final String X_ONAP_PARTNER_NAME = "X-ONAP-PartnerName"; final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); private static final String START = " start"; private final SyncRestClient client; private final String baseUrl; + private final SystemPropertiesWrapper systemProperties; private final Map<String, String> commonHeaders; + /** * The logger. */ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class); - public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient, SystemPropertiesWrapper systemPropertiesWrapper, Logging loggingService) { - super(authClient,systemPropertiesWrapper, loggingService); + public MsoRestClientNew(SyncRestClient client, String baseUrl, SystemPropertiesWrapper systemPropertiesWrapper) { this.client = client; this.baseUrl = baseUrl; + this.systemProperties = systemPropertiesWrapper; this.commonHeaders = initCommonHeaders(); } @@ -482,14 +483,6 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf return client.post(path, getHeaders(), requestDetailsWrapper, responseClass); } - @Override - public <T> HttpResponse<T> post(String endpoint, RequestDetails requestDetails, Class<T> responseClass) { - String path = baseUrl + endpoint; - - return client.post(path, getHeaders(), requestDetails, responseClass); - } - - public HttpResponse<SOWorkflowList> getWorkflowListByModelId(String endpoint){ String path = baseUrl + endpoint; @@ -545,6 +538,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf String requestIdValue = Logging.extractOrGenerateRequestId(); map.put(SystemProperties.ECOMP_REQUEST_ID, requestIdValue); map.put(ONAP_REQUEST_ID_HEADER_KEY, requestIdValue); + map.put(Headers.INVOCATION_ID.getHeaderName(), Headers.INVOCATION_ID.getHeaderValue()); return map; } @@ -563,7 +557,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf map.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); map.put(X_FROM_APP_ID, systemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)); - map.put(X_ONAP_PARTNER_NAME, "VID"); + map.put(PARTNER_NAME.getHeaderName(), PARTNER_NAME.getHeaderValue()); return ImmutableMap.copyOf(map); } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java deleted file mode 100644 index 3a0d8fd8e..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 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.vid.mso.rest; - -import org.onap.vid.changeManagement.RequestDetailsWrapper; -import org.onap.vid.mso.RestObject; -import org.onap.vid.mso.RestObjectWithRequestInfo; - -/** - * Created by pickjonathan on 26/06/2017. - */ -public interface RestInterface { - - /** - * Gets the. - * - * @param <T> the generic type - * @param t the t - * @param path the path - * @param restObject the rest object - * @param warpException - * @throws Exception the exception - */ - <T> RestObjectWithRequestInfo<T> Get(T t, String path, RestObject<T> restObject, boolean warpException); - - /** - * Delete. - * - * @param <T> the generic type - * @param t the t - * @param r the r - * @param path the path - * @param restObject the rest object - * @throws Exception the exception - */ - <T> void Delete(T t, Object r, String path, RestObject<T> restObject); - - /** - * Post. - * - * @param t the t - * @param r the r - * @param path the path - * @param restObject the rest object - * @throws Exception the exception - */ - void Post(String t, Object r, String path, RestObject<String> restObject); - - /** - * Put. - * - * @param <T> the generic type - * @param t the t - * @param r the r - * @param path the path - * @param restObject the rest object - * @throws Exception the exception - */ - <T> void Put(T t, RequestDetailsWrapper r, String path, RestObject<T> restObject); - - <T> RestObject<T> GetForObject(String path, Class<T> clazz); - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java index 7384c97e2..a3343d36b 100644 --- a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java +++ b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java @@ -74,6 +74,7 @@ public enum Features implements Feature { FLAG_PNP_INSTANTIATION, FLAG_HANDLE_SO_WORKFLOWS, FLAG_CREATE_ERROR_REPORTS, + FLAG_SHOW_ORCHESTRATION_TYPE, FLAG_DISABLE_HOMING, FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG, FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT, diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java index b6404fa68..b64a233c7 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java @@ -75,7 +75,6 @@ import org.onap.vid.aai.model.RelationshipData; import org.onap.vid.aai.model.RelationshipList; import org.onap.vid.aai.model.Result; import org.onap.vid.aai.model.ServiceRelationships; -import org.onap.vid.aai.model.VnfResult; import org.onap.vid.asdc.beans.Service; import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.model.ServiceInstanceSearchResult; @@ -137,7 +136,9 @@ public class AaiServiceImpl implements AaiService { .setToscaModelURL(null) .setLifecycleState(null) .setArtifacts(null) - .setResources(null).build(); + .setResources(null) + .setOrchestrationType(modelVer.getOrchestrationType()) + .build(); @@ -150,6 +151,10 @@ public class AaiServiceImpl implements AaiService { return services; } + private boolean hasData(AaiResponse<?> aaiResponse) { + return aaiResponse != null && aaiResponse.getT() != null; + } + private boolean validateModel(Model model){ if (model == null) { return false; @@ -388,24 +393,7 @@ public class AaiServiceImpl implements AaiService { @Override public AaiResponse<AaiGetVnfResponse> getVNFData(String globalSubscriberId, String serviceType) { AaiResponse<AaiGetVnfResponse> response = aaiClient.getVNFData(globalSubscriberId, serviceType); - return filterChangeManagementVNFCandidatesResponse(response); - } - - protected AaiResponse<AaiGetVnfResponse> filterChangeManagementVNFCandidatesResponse(AaiResponse<AaiGetVnfResponse> response) { - - if (response != null && response.getT() != null) { - List<VnfResult> filteredVnfs = response.getT().results.stream() - .filter(result -> ( - result.nodeType.equalsIgnoreCase("generic-vnf") || - result.nodeType.equalsIgnoreCase("service-instance"))) - .collect(Collectors.toList()); - - AaiGetVnfResponse aaiGetVnfResponse = new AaiGetVnfResponse(); - aaiGetVnfResponse.results = filteredVnfs; - return new AaiResponse<>(aaiGetVnfResponse, response.getErrorMessage(), response.getHttpCode()); - } - - return new AaiResponse<>(); + return hasData(response) ? response : new AaiResponse<>(); } @Override diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties index db2ff8e97..d4910bf25 100644 --- a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties +++ b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties @@ -36,3 +36,4 @@ FLAG_DISABLE_HOMING = true FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH=false FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG = false FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE = false +FLAG_SHOW_ORCHESTRATION_TYPE = false diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/onap.features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/onap.features.properties index d1ce91f44..709de9566 100644 --- a/vid-app-common/src/main/webapp/WEB-INF/conf/onap.features.properties +++ b/vid-app-common/src/main/webapp/WEB-INF/conf/onap.features.properties @@ -15,6 +15,7 @@ FLAG_1810_AAI_LOCAL_CACHE = true FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER = false FLAG_HANDLE_SO_WORKFLOWS = true FLAG_CREATE_ERROR_REPORTS = true +FLAG_SHOW_ORCHESTRATION_TYPE = false # Modern UI (Drawing-Board; View/Edit) # - - - - - - - - - - - - - - - - - - diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js index f76d4786f..3575c382d 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js @@ -264,6 +264,7 @@ appDS2 FLAG_1908_RELEASE_TENANT_ISOLATION: "FLAG_1908_RELEASE_TENANT_ISOLATION", FLAG_FLASH_REPLACE_VF_MODULE: "FLAG_FLASH_REPLACE_VF_MODULE", FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT: "FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT", + FLAG_SHOW_ORCHESTRATION_TYPE: "FLAG_SHOW_ORCHESTRATION_TYPE", } }; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js index 9cb905038..b29680f9d 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js @@ -89,6 +89,10 @@ });
};
+ $scope.isShowOrchestrationType = function() {
+ return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ORCHESTRATION_TYPE);
+ };
+
var wholeData=[];
$scope.filterDataWithHigherVersion = function(serviceData){
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js index d966df8d9..9eed4c14d 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js @@ -541,7 +541,7 @@ }); }; - function isCompatibleVNFRole(vnf) { + function isCompatibleNFRole(vnf) { return vnf.properties['nf-role'] === vm.changeManagement['vnfType'] || !vm.changeManagement['vnfType']; @@ -549,7 +549,7 @@ function isValidVnf(vnf) { - let result = isCompatibleVNFRole(vnf) && vnf.properties["model-invariant-id"] + let result = isCompatibleNFRole(vnf) && vnf.properties["model-invariant-id"] && vnf.properties["model-version-id"]; return result; @@ -577,9 +577,9 @@ vm.vnfTypes = []; vm.vnfTypesTemp = []; vm.serviceInstances = []; - vm.fromVNFVersions=[]; - vm.vnfNames =[]; - vm.changeManagement.vnfNames =[]; + vm.fromVNFVersions = []; + vm.vnfNames = []; + vm.changeManagement.vnfNames = []; var instances = vm.changeManagement.serviceType["service-instances"]["service-instance"]; // var promiseArrOfGetVnfs = preparePromiseArrOfGetVnfs(instances); @@ -723,7 +723,7 @@ }; vm.loadVNFNames = function () { - vm.changeManagement.vnfNames =[]; + vm.changeManagement.vnfNames = []; vm.vnfNames = []; const vnfs = vm.changeManagement.fromVNFVersion ? vm.vnfs : []; @@ -731,7 +731,7 @@ var selectedVersionNumber = getVersionNameForId(vm.changeManagement.fromVNFVersion); - if (isCompatibleVNFRole(vnf) && + if (isCompatibleNFRole(vnf) && selectedVersionNumber === getVersionNameForId(vnf.properties["model-version-id"])) { var vServer = {}; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm index 4570a0b08..06fc7f67b 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm @@ -48,6 +48,7 @@ <tr>
<th att-table-header key="action">Action</th>
<th att-table-header key="uuid">UUID</th>
+ <th ng-if="isShowOrchestrationType()" att-table-header key="orchestrationType">Orchestration Type</th>
<th att-table-header key="invariantUUID">Invariant UUID</th>
<th att-table-header default-sort="A" key="name">Name</th>
<th att-table-header key="version">Version</th>
@@ -62,6 +63,7 @@ <tr class="sdcServiceModel" data-tests-id="Browse_SDC_Service_Models-uuid-{{service['uuid']}}">
<td class="deploy" att-table-body ><button class="deploy-service-class" type=button data-tests-id="deploy-{{service['uuid']}}" ng-click="deployService(service)" att-button btn-type="{{deployButtonType}}" size="small">Deploy</button></td>
<td class="uuid" att-table-body ng-bind="service['uuid']"></td>
+ <td ng-if="isShowOrchestrationType()" class="orchestrationType" att-table-body ng-bind="service['orchestrationType']"></td>
<td class="invariantUUID" att-table-body data-tests-id="Invariant-{{service['invariantUUID']}}" ng-bind="service['invariantUUID']"></td>
<td class="name" att-table-body ng-bind="service['name']"></td>
<td class="version" att-table-body ng-bind="service['version']"></td>
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java index bf8a5a1bc..2076d83ef 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java @@ -22,7 +22,6 @@ package org.onap.vid.aai.util; import static javax.ws.rs.core.Response.Status.BAD_REQUEST; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static javax.ws.rs.core.Response.Status.OK; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -166,12 +165,12 @@ public class AAIRestInterfaceTest { Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON); // when + when(builder.build(any(), any())).thenReturn(invocation); + when(invocation.invoke()).thenReturn(response); when(builder.post(Mockito.any(Entity.class))).thenReturn(response); when(response.getStatusInfo()).thenReturn(OK); Response finalResponse = testSubject.RestPost("", PATH, payload, false); - // then - verify(builder).post(entity); Assert.assertEquals(response, finalResponse); } @@ -182,13 +181,13 @@ public class AAIRestInterfaceTest { Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON); // when - when(builder.post(Mockito.any(Entity.class))).thenReturn(response); + when(builder.build(any(), any())).thenReturn(invocation); + when(invocation.invoke()).thenReturn(response); when(response.getStatusInfo()).thenReturn(BAD_REQUEST); when(response.getStatus()).thenReturn(BAD_REQUEST.getStatusCode()); Response finalResponse = testSubject.RestPost("", PATH, payload, false); // then - verify(builder).post(entity); Assert.assertEquals(response, finalResponse); } @@ -199,58 +198,15 @@ public class AAIRestInterfaceTest { Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON); // when - when(builder.post(Mockito.any(Entity.class))).thenThrow(new RuntimeException()); + when(builder.build(any(), any())).thenReturn(invocation); + when(invocation.invoke()).thenThrow(new RuntimeException()); Response finalResponse = testSubject.RestPost("", PATH, payload, false); // then - verify(builder).post(entity); Assert.assertNull(finalResponse); } @Test - public void shouldExecuteRestDeleteMethodWithResponse400() { - // given - // when - when(builder.delete()).thenReturn(response); - when(response.getStatusInfo()).thenReturn(BAD_REQUEST); - String reason = "Any reason"; - when(response.readEntity(String.class)).thenReturn(reason); - when(response.getStatus()).thenReturn(BAD_REQUEST.getStatusCode()); - boolean finalResponse = testSubject.Delete("", "", PATH); - - // then - verify(builder).delete(); - Assert.assertFalse(finalResponse); - } - - @Test - public void shouldExecuteRestDeleteMethodWithResponse404() { - // given - // when - when(builder.delete()).thenReturn(response); - when(response.getStatusInfo()).thenReturn(NOT_FOUND); - String reason = "Any reason"; - when(response.readEntity(String.class)).thenReturn(reason); - when(response.getStatus()).thenReturn(NOT_FOUND.getStatusCode()); - boolean finalResponse = testSubject.Delete("", "", PATH); - - // then - verify(builder).delete(); - Assert.assertFalse(finalResponse); - } - - @Test - public void shouldFailWhenRestDeleteExecuted() { - // given - // when - when(builder.delete()).thenThrow(new RuntimeException()); - boolean finalResponse = testSubject.Delete("", "", PATH); - // then - verify(builder).delete(); - Assert.assertFalse(finalResponse); - } - - @Test public void shouldExecuteRestGetMethodWithResponse200() { // given // when diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/ParametrizedAAIRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/ParametrizedAAIRestInterfaceTest.java deleted file mode 100644 index c0d3b962f..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/aai/util/ParametrizedAAIRestInterfaceTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2018 - 2019 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.vid.aai.util; - -import static javax.ws.rs.core.Response.Status.NO_CONTENT; -import static javax.ws.rs.core.Response.Status.OK; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.Collection; -import java.util.Optional; -import java.util.UUID; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Response; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.onap.vid.aai.exceptions.InvalidPropertyException; -import org.onap.vid.utils.Logging; -import org.testng.Assert; - -@RunWith(Parameterized.class) -public class ParametrizedAAIRestInterfaceTest { - - private static final String PATH = "path"; - private static final String HTTP_LOCALHOST = "http://localhost/"; - @Mock - private Client client; - @Mock - private WebTarget webTarget; - @Mock - private Invocation.Builder builder; - @Mock - private ServletRequestHelper servletRequestHelper; - @Mock - private HttpsAuthClient httpsAuthClient; - @Mock - private HttpServletRequest httpServletRequest; - @Mock - private Response response; - @Mock - private SystemPropertyHelper systemPropertyHelper; - @Mock - private Logging loggingService; - - private AAIRestInterface testSubject; - private Response.Status status; - - @Parameterized.Parameters - public static Collection<Object> data() { - return Arrays.asList(OK, NO_CONTENT); - } - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - mockSystemProperties(); - testSubject = createTestSubject(); - when(client.target(HTTP_LOCALHOST+PATH)).thenReturn(webTarget); - when(webTarget.request()).thenReturn(builder); - when(builder.accept(Mockito.anyString())).thenReturn(builder); - when(builder.header(Mockito.anyString(), Mockito.anyString())).thenReturn(builder); - when(servletRequestHelper.extractOrGenerateRequestId()).thenReturn(UUID.randomUUID().toString()); - } - - public ParametrizedAAIRestInterfaceTest(Response.Status status) { - this.status = status; - } - - private AAIRestInterface createTestSubject() { - return new AAIRestInterface(Optional.of(client), httpsAuthClient, servletRequestHelper, systemPropertyHelper, loggingService); - } - - @Test - public void testRestDeleteWithValidResponse() { - - // when - when(builder.delete()).thenReturn(response); - when(response.getStatusInfo()).thenReturn(status); - boolean finalResponse = testSubject.Delete("", "", PATH); - - // then - verify(builder).delete(); - Assert.assertTrue(finalResponse); - } - - private void mockSystemProperties() throws UnsupportedEncodingException, InvalidPropertyException { - when(systemPropertyHelper.getAAIServerUrl()).thenReturn(Optional.of(HTTP_LOCALHOST)); - when(systemPropertyHelper.getAAIUseClientCert()).thenReturn(Optional.of("cert")); - when(systemPropertyHelper.getAAIVIDPasswd()).thenReturn(Optional.of("passwd")); - when(systemPropertyHelper.getAAIVIDUsername()).thenReturn(Optional.of("user")); - when(systemPropertyHelper.getEncodedCredentials()).thenReturn("someCredentials"); - when(systemPropertyHelper.getFullServicePath(Mockito.anyString())).thenReturn("http://localhost/path"); - } - -} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java index fd946ebde..7cbf0805b 100644 --- a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java @@ -24,10 +24,14 @@ import static com.xebialabs.restito.semantics.Action.ok; import static com.xebialabs.restito.semantics.Action.stringContent; import static org.apache.http.client.config.RequestConfig.custom; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.equalToIgnoringCase; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.matchesPattern; import static org.hamcrest.collection.IsIterableContainingInOrder.contains; +import static org.hamcrest.collection.IsMapContaining.hasEntry; +import static org.hamcrest.collection.IsMapContaining.hasKey; +import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID; @@ -125,10 +129,12 @@ public class SdcRestClientITTest { assertTrue(first.isPresent()); - assertThat(first.get().getHeaders().keySet(), - hasItems(X_ECOMP_INSTANCE_ID.toLowerCase(), REQUEST_ID_HEADER_KEY.toLowerCase())); - assertThat(first.get().getHeaders().get(REQUEST_ID_HEADER_KEY.toLowerCase()).get(0), - matchesPattern(UUID_REGEX)); + assertThat(first.get().getHeaders(), + allOf( + hasEntry(equalToIgnoringCase(REQUEST_ID_HEADER_KEY), contains(matchesPattern(UUID_REGEX))), + hasKey(equalToIgnoringCase(X_ECOMP_INSTANCE_ID)), + hasEntry(equalToIgnoringCase("x-onap-partnerName"), contains(equalTo("VID.VID"))) + )); } private Service getExpectedService(String stringId) { diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java index 43edeebe9..03a6c40f3 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java @@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletRequest; import org.junit.Test; import org.onap.vid.mso.MsoBusinessLogicImpl; import org.onap.vid.mso.MsoInterface; -import org.onap.vid.mso.rest.MsoRestClientNew; +import org.onap.vid.mso.RestMsoImplementation; import org.onap.vid.mso.rest.RequestDetails; import org.onap.vid.mso.rest.RequestDetailsWrapper; import org.onap.vid.services.CloudOwnerServiceImpl; @@ -36,7 +36,7 @@ public class MsoControllerNewTest { private MsoController createTestSubject() { try { - return new MsoController(new MsoBusinessLogicImpl(mock(MsoInterface.class)), mock(MsoRestClientNew.class), + return new MsoController(new MsoBusinessLogicImpl(mock(MsoInterface.class)), mock(RestMsoImplementation.class), new CloudOwnerServiceImpl(null, null)); } catch (Exception e) { return null; diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java index 5aa6505d4..09f0fd357 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java @@ -50,8 +50,8 @@ import org.onap.vid.model.RequestReferencesContainer; import org.onap.vid.mso.MsoBusinessLogic; import org.onap.vid.mso.MsoResponseWrapper; import org.onap.vid.mso.MsoResponseWrapper2; +import org.onap.vid.mso.RestMsoImplementation; import org.onap.vid.mso.RestObject; -import org.onap.vid.mso.rest.MsoRestClientNew; import org.onap.vid.mso.rest.Request; import org.onap.vid.mso.rest.RequestDetails; import org.onap.vid.mso.rest.RequestDetailsWrapper; @@ -73,13 +73,13 @@ public class MsoControllerTest { private MockMvc mockMvc; private MsoBusinessLogic msoBusinessLogic; private CloudOwnerService cloudService; - private MsoRestClientNew msoRestClient; + private RestMsoImplementation msoRestClient; @Before public void setUp() { msoBusinessLogic = mock(MsoBusinessLogic.class); cloudService = mock(CloudOwnerService.class); - msoRestClient = mock(MsoRestClientNew.class); + msoRestClient = mock(RestMsoImplementation.class); MsoController msoController = new MsoController(msoBusinessLogic, msoRestClient, cloudService); mockMvc = MockMvcBuilders.standaloneSetup(msoController).build(); diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java index 9501614b7..986f5d0f5 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java @@ -20,8 +20,45 @@ package org.onap.vid.job.command; +import static java.util.Collections.emptyList; +import static org.mockito.AdditionalAnswers.returnsFirstArg; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.RETURNS_MOCKS; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.onap.vid.job.command.ResourceCommandKt.ACTION_PHASE; +import static org.onap.vid.job.command.ResourceCommandKt.INTERNAL_STATE; +import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.createGroup; +import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.createMember; +import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.createNetwork; +import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.createService; +import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.createVfModule; +import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.createVnf; +import static org.onap.vid.model.Action.Create; +import static org.onap.vid.model.Action.Delete; +import static org.onap.vid.model.Action.None; +import static org.onap.vid.model.Action.Resume; +import static org.onap.vid.model.Action.values; +import static org.onap.vid.utils.Logging.getMethodCallerName; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.ws.rs.ProcessingException; +import kotlin.Pair; import org.jetbrains.annotations.NotNull; import org.onap.vid.exceptions.AbortingException; import org.onap.vid.exceptions.GenericUncheckedException; @@ -32,32 +69,19 @@ import org.onap.vid.job.JobsBrokerService; import org.onap.vid.job.NextCommand; import org.onap.vid.job.impl.JobSharedData; import org.onap.vid.model.Action; -import org.onap.vid.model.serviceInstantiation.*; +import org.onap.vid.model.serviceInstantiation.BaseResource; +import org.onap.vid.model.serviceInstantiation.InstanceGroup; +import org.onap.vid.model.serviceInstantiation.InstanceGroupMember; +import org.onap.vid.model.serviceInstantiation.Network; +import org.onap.vid.model.serviceInstantiation.ServiceInstantiation; +import org.onap.vid.model.serviceInstantiation.VfModule; +import org.onap.vid.model.serviceInstantiation.Vnf; import org.onap.vid.mso.RestMsoImplementation; import org.onap.vid.mso.model.ModelInfo; import org.springframework.http.HttpMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import javax.ws.rs.ProcessingException; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.Collections.emptyList; -import static org.mockito.AdditionalAnswers.returnsFirstArg; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; -import static org.onap.vid.job.command.ResourceCommandKt.ACTION_PHASE; -import static org.onap.vid.job.command.ResourceCommandKt.INTERNAL_STATE; -import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.*; -import static org.onap.vid.model.Action.*; -import static org.onap.vid.utils.Logging.getMethodCallerName; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; - public class ResourceCommandTest { public static class MockCommand extends ResourceCommand { @@ -503,4 +527,30 @@ public class ResourceCommandTest { assertEquals(expectedNextStatus, nextCommand.getStatus()); } + @DataProvider + public static Object[][] resourcePosition() { + return new Object[][]{ + {1, 2, 3, ImmutableList.of(1,2,3)}, + {null, 1, 100, ImmutableList.of(101,1,100)}, + {null, null, null, ImmutableList.of(1,2,3)}, + {1,2,2, ImmutableList.of(1,2,2)} + }; + } + + @Test(dataProvider = "resourcePosition") + public void sortChildren_sortAccordingToPosition(Integer firstPosition, Integer secondPosition, Integer thirdPosition, List<Integer> expectedPositions){ + BaseResource mockedRequest1 = mock(BaseResource.class); + when(mockedRequest1.getPosition()).thenReturn(firstPosition); + BaseResource mockedRequest2 = mock(BaseResource.class); + when(mockedRequest2.getPosition()).thenReturn(secondPosition); + BaseResource mockedRequest3 = mock(BaseResource.class); + when(mockedRequest3.getPosition()).thenReturn(thirdPosition); + + MockCommand underTest = new MockCommand(InternalState.CREATING_CHILDREN, Create, Job.JobStatus.IN_PROGRESS); + List<Pair<BaseResource, Integer>> sortedList = underTest.setPositionWhereIsMissing(ImmutableList.of(mockedRequest1, mockedRequest2, mockedRequest3)); + + assertEquals(sortedList.get(0).getSecond(),expectedPositions.get(0)); + assertEquals(sortedList.get(1).getSecond(),expectedPositions.get(1)); + assertEquals(sortedList.get(2).getSecond(),expectedPositions.get(2)); + } } diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java index 787ff608d..992325049 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java @@ -143,9 +143,14 @@ public class ServiceInProgressStatusCommandTest { UUID uuid = UUID.randomUUID(); String userId = "mockedUserID"; String testApi = "VNF_API"; + + // Create components setPosition in order to verify on the creation order on createChildJob + Network network = createNetwork(Create); + network.setPosition(0); Vnf vnf1 = createVnf(emptyList(), Create); + vnf1.setPosition(1); Vnf vnf2 = createVnf(emptyList(), Create); - Network network = createNetwork(Create); + vnf2.setPosition(2); ServiceInstantiation serviceInstantiation = createService( ImmutableList.of(vnf1, vnf2), ImmutableList.of(network), diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java index 558dc269f..83fff4f5d 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java @@ -1255,7 +1255,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests { UUID workflow_UUID = new UUID(3,30); String path = "/instanceManagement/v1/serviceInstances/"+serviceInstanceId+"/vnfs/"+vnfInstanceId+"/workflows/"+workflow_UUID; - given(msoInterface.invokeWorkflow(eq(request), eq(path), MockitoHamcrest.argThat(allOf(hasEntry("X-RequestorID", "testRequester"),hasEntry("X-ONAP-PartnerName", "VID"))))).willReturn(okResponse); + given(msoInterface.invokeWorkflow(eq(request), eq(path), MockitoHamcrest.argThat(allOf(hasEntry("X-RequestorID", "testRequester"),hasEntry("X-ONAP-PartnerName", "VID.VID"))))).willReturn(okResponse); // when MsoResponseWrapper response = msoBusinessLogic.invokeVnfWorkflow(request, "testRequester", serviceInstanceId, vnfInstanceId, workflow_UUID); diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java index e1b78740a..792435002 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java @@ -37,13 +37,12 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; +import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.JerseyInvocation; import org.mockito.InjectMocks; import org.mockito.Mock; import org.onap.vid.aai.util.HttpClientMode; import org.onap.vid.aai.util.HttpsAuthClient; -import org.onap.vid.changeManagement.RequestDetailsWrapper; -import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.mso.rest.RequestDetails; import org.onap.vid.utils.Logging; import org.onap.vid.utils.SystemPropertiesWrapper; @@ -104,46 +103,6 @@ public class RestMsoImplementationTest { assertThat(result).doesNotContainKey("notExistingKey"); } - @Test - public void shouldProperlyGetRestObjectWithRequestInfo() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks(rawData, HttpStatus.ACCEPTED.value(),""); - - // when - RestObjectWithRequestInfo<HttpRequest> response = restMsoImplementation.Get(httpRequest, path, restObject,false); - - // then - assertThat(response.getRequestedUrl()).contains(path); - assertThat(response.getRawData()).isEqualTo(rawData); - assertThat(response.getHttpCode()).isEqualTo(HttpStatus.ACCEPTED.value()); - assertThat(response.getHttpMethod()).isEqualTo(HttpMethod.GET); - } - - @Test( expectedExceptions = GenericUncheckedException.class) - public void shouldThrowExceptionWhenGetRestObjectWithRequestInfoGetsWrongStatus() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks("",HttpStatus.BAD_REQUEST.value(),""); - - // when - restMsoImplementation.Get(httpRequest, "", restObject,false); - } - - @Test( expectedExceptions = MsoTestException.class) - public void shouldThrowExceptionWhenGetRestObjectWithRequestInfoGetsWrongParameters() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks("",HttpStatus.ACCEPTED.value(),""); - when(systemProperties.getProperty(MsoProperties.MSO_SERVER_URL)).thenReturn("SAMPLE_URL"); - when(mockClient.target("SAMPLE_URL")).thenThrow(new MsoTestException("test-target-exception")); - - // when - restMsoImplementation.Get(httpRequest, "", restObject,false); - } @Test() public void shouldProperlyGetRestObjectForObjectWithRequestInfoAndAcceptCode() { @@ -171,79 +130,6 @@ public class RestMsoImplementationTest { assertThat(response.getRaw()).isEqualTo(rawData); } - @Test() - public void shouldProperlyDeleteRestObjectWithStatusHttpAccepted() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE"); - - // when - restMsoImplementation.Delete(httpRequest, "testObject", path, restObject); - - // then - assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED.value()); - } - - @Test() - public void shouldProperlyDeleteRestObjectWithStatusOK() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks(rawData,HttpStatus.OK.value(),"DELETE"); - - // when - restMsoImplementation.Delete(httpRequest, "testObject", path, restObject); - - // then - assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.OK.value()); - } - - @Test() - public void shouldProperlyReturnFromDeleteWithStatusBadRequest() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks(rawData,HttpStatus.BAD_REQUEST.value(),"DELETE"); - - // when - restMsoImplementation.Delete(httpRequest, "testObject", path, restObject); - - // then - assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST.value()); - } - - @Test() - public void shouldProperlyReturnFromDeleteWithStatusOtherThenAbove() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - prepareMocks(rawData,HttpStatus.NOT_EXTENDED.value(),"DELETE"); - - // when - restMsoImplementation.Delete(httpRequest, "testObject", path, restObject); - - // then - assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.NOT_EXTENDED.value()); - } - - @Test( expectedExceptions = MsoTestException.class) - public void shouldThrowExceptionWhenCallsDeleteWithWrongParameters() { - // given - when(mockClient.target(any(String.class))).thenThrow(new MsoTestException("testDeleteException")); - - // when - restMsoImplementation.Delete(httpRequest, "testObject", "", null); - } - - @Test( expectedExceptions = NullPointerException.class) - public void shouldThrowExceptionWhenCallsDeleteWithWrongObjectType() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE"); - - // when - restMsoImplementation.Delete(null, "testObject", path, restObject); - } @Test public void shouldProperlyPostForObject() { @@ -264,43 +150,6 @@ public class RestMsoImplementationTest { } @Test - public void shouldProperlyDeleteForObject() { - // given - RequestDetails requestDetails = new RequestDetails(); - - RestObject<HttpRequest> expectedResponse = new RestObject<>(); - expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value()); - expectedResponse.setRaw(rawData); - - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE"); - - // when - RestObject<HttpRequest> response = restMsoImplementation.DeleteForObject(requestDetails, path, HttpRequest.class); - - // then - assertThat(response).isEqualToComparingFieldByField(expectedResponse); - } - - @Test - public void shouldProperlyPost() { - // given - RequestDetails requestDetails = new RequestDetails(); - RestObject<String> response = new RestObject<>(); - - RestObject<String> expectedResponse = new RestObject<>(); - expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value()); - expectedResponse.setRaw(rawData); - - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"POST"); - - // when - restMsoImplementation.Post(rawData,requestDetails, path, response); - - // then - assertThat(response).isEqualToComparingFieldByField(expectedResponse); - } - - @Test public void shouldProperlyPrepareClient() { // given String method = "POST"; @@ -339,70 +188,6 @@ public class RestMsoImplementationTest { restMsoImplementation.restCall(HttpMethod.GET, String.class, null, "", Optional.empty()); } - @Test - public void shouldProperlyPutRestObjectWithProperParametersAndStatusAccepted() { - // given - String method = "PUT"; - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),method); - - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - RestObject<String> response = new RestObject<>(); - - RestObject<String> expectedResponse = new RestObject<>(); - expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value()); - expectedResponse.set(rawData); - - // when - restMsoImplementation.Put("testPutBody", requestDetailsWrapper , path, response); - - // then - assertThat(response).isEqualToComparingFieldByField(expectedResponse); - } - - @Test - public void shouldProperlyPutRestObjectWithProperParametersAndStatusMultipleChoices() { - // given - String method = "PUT"; - prepareMocks(rawData,HttpStatus.MULTIPLE_CHOICES.value(),method); - - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - RestObject<String> response = new RestObject<>(); - - RestObject<String> expectedResponse = new RestObject<>(); - expectedResponse.setStatusCode(HttpStatus.MULTIPLE_CHOICES.value()); - expectedResponse.set(rawData); - - // when - restMsoImplementation.Put("testPutBody", requestDetailsWrapper , path, response); - - // then - assertThat(response).isEqualToComparingFieldByField(expectedResponse); - } - - @Test( expectedExceptions = MsoTestException.class) - public void shouldThrowExceptionWhenCallsPutWithWrongParameters() { - // given - when(mockClient.target(any(String.class))).thenThrow(new MsoTestException("testDeleteException")); - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - - // when - restMsoImplementation.Put(null, requestDetailsWrapper, "", null); - } - - @Test( expectedExceptions = NullPointerException.class) - public void shouldThrowExceptionWhenCallsPutWithWrongObjectType() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE"); - - // when - restMsoImplementation.Put(null, requestDetailsWrapper, path, restObject); - } - - - private void prepareMocks(String rawData,int status,String httpMethod) { when(mockClient.target(any(String.class))).thenReturn(webTarget); @@ -411,6 +196,7 @@ public class RestMsoImplementationTest { when(builder.accept(any(String.class))).thenReturn(builder); when(builder.headers(any(MultivaluedMap.class))).thenReturn(builder); + when(builder.property(eq(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION), eq(true))).thenReturn(builder); when(builder.get()).thenReturn(response); when(builder.build( eq(httpMethod), any(Entity.class))).thenReturn(jerseyInvocation); diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java index 457007500..aaaa324e8 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java @@ -410,7 +410,7 @@ public class MsoRestClientNewTest { String sourceId = ""; String endpoint = ""; final SyncRestClient client = mock(SyncRestClient.class); - MsoRestClientNew testSubject = new MsoRestClientNew(client, "", null, new SystemPropertiesWrapper(), mock(Logging.class)); + MsoRestClientNew testSubject = new MsoRestClientNew(client, "", new SystemPropertiesWrapper()); // setup final HttpResponse<String> response = mock(HttpResponse.class); @@ -474,10 +474,10 @@ public class MsoRestClientNewTest { private MsoRestClientNew msoRestClient() { return new MsoRestClientNew(new SyncRestClient(JOSHWORKS_JACKSON_OBJECT_MAPPER, mock(Logging.class)), - baseUrl(), null, new SystemPropertiesWrapper(), mock(Logging.class)); + baseUrl(), new SystemPropertiesWrapper()); } private MsoRestClientNew createTestSubject() { - return new MsoRestClientNew(null, "", null, new SystemPropertiesWrapper(), mock(Logging.class)); + return new MsoRestClientNew(null, "", new SystemPropertiesWrapper()); } } diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java index 5486becad..dd05a625e 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java @@ -99,7 +99,7 @@ public class MsoRestClientTest { initMocks(this); when(systemProperties.getProperty(MsoProperties.MSO_PASSWORD)).thenReturn("OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz"); when(systemProperties.getProperty("app_display_name")).thenReturn("vid"); - restClient = new MsoRestClientNew(client,baseUrl,null,systemProperties,loggingService); + restClient = new MsoRestClientNew(client, baseUrl, systemProperties); } @Test @@ -832,7 +832,7 @@ public class MsoRestClientTest { Map<String,String> extraHeaders = new HashMap<>(); extraHeaders.put("X-ONAP-RequestID",requestId.toString()); - extraHeaders.put("X-ONAP-PartnerName","VID"); + extraHeaders.put("X-ONAP-PartnerName","VID.VID"); extraHeaders.put("X-RequestorID","testRequester"); // when diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java index ac82a6e53..123737f4f 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java @@ -32,7 +32,7 @@ import static com.xebialabs.restito.semantics.Condition.post; import static com.xebialabs.restito.semantics.Condition.uri; import static com.xebialabs.restito.semantics.Condition.withHeader; import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals; -import static org.onap.vid.mso.rest.MsoRestClientNew.X_ONAP_PARTNER_NAME; +import static org.onap.vid.logging.Headers.PARTNER_NAME; import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY; import com.fasterxml.jackson.databind.ObjectMapper; @@ -235,7 +235,7 @@ class MsoRestClientTestUtil implements AutoCloseable { withHeader(HttpHeaders.ACCEPT), withHeader(HttpHeaders.CONTENT_TYPE), withHeader(MsoRestClientNew.X_FROM_APP_ID), - withHeader(X_ONAP_PARTNER_NAME, "VID"), + withHeader(PARTNER_NAME.getHeaderName(), "VID.VID"), withHeader(SystemProperties.ECOMP_REQUEST_ID), withHeader(ONAP_REQUEST_ID_HEADER_KEY) ); diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java index ac05ea706..cfb9ee6ea 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java @@ -20,16 +20,32 @@ package org.onap.vid.mso.rest; +import static org.apache.commons.io.IOUtils.toInputStream; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasToString; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableList; +import io.joshworks.restclient.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.function.Consumer; @@ -38,6 +54,7 @@ import java.util.stream.Stream; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.client.Client; import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.Invocation.Builder; import javax.ws.rs.core.MultivaluedMap; import org.apache.commons.lang3.reflect.FieldUtils; import org.mockito.ArgumentCaptor; @@ -47,13 +64,21 @@ import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.util.AAIRestInterface; +import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.aai.util.ServletRequestHelper; import org.onap.vid.aai.util.SystemPropertyHelper; +import org.onap.vid.client.SyncRestClient; import org.onap.vid.controller.filter.PromiseRequestIdFilter; +import org.onap.vid.logging.Headers; +import org.onap.vid.mso.MsoProperties; +import org.onap.vid.mso.RestMsoImplementation; import org.onap.vid.testUtils.TestUtils; import org.onap.vid.utils.Logging; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.onap.vid.utils.Unchecked; +import org.springframework.http.HttpMethod; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -67,18 +92,29 @@ public class OutgoingRequestHeadersTest { private static final PromiseRequestIdFilter promiseRequestIdFilter = new PromiseRequestIdFilter(); -// @InjectMocks -// private RestMsoImplementation restMsoImplementation; + @InjectMocks + private RestMsoImplementation restMsoImplementation; + + private MsoRestClientNew msoRestClientNew; @Mock private SystemPropertyHelper systemPropertyHelper; @Mock + private SystemPropertiesWrapper systemPropertiesWrapper; + + @Mock + private HttpsAuthClient httpsAuthClient; + + @Mock private ServletRequestHelper servletRequestHelper; @Mock private Logging loggingService; + @Mock + SyncRestClient syncRestClient; + @InjectMocks private AAIRestInterface aaiRestInterface; @@ -88,7 +124,12 @@ public class OutgoingRequestHeadersTest { @BeforeClass public void initMocks() { MockitoAnnotations.initMocks(this); - when(servletRequestHelper.extractOrGenerateRequestId()).thenAnswer(invocation -> UUID.randomUUID().toString()); + String oneIncomingRequestId = UUID.randomUUID().toString(); + when(servletRequestHelper.extractOrGenerateRequestId()).thenReturn(oneIncomingRequestId); + when(systemPropertiesWrapper.getProperty(MsoProperties.MSO_PASSWORD)).thenReturn("OBF:1vub1ua51uh81ugi1u9d1vuz"); + when(systemPropertiesWrapper.getProperty(SystemProperties.APP_DISPLAY_NAME)).thenReturn("vid"); + //the ctor of MsoRestClientNew require the above lines as preconditions + msoRestClientNew = new MsoRestClientNew(syncRestClient, "baseUrl",systemPropertiesWrapper); } @BeforeMethod @@ -101,50 +142,110 @@ public class OutgoingRequestHeadersTest { (HttpServletRequest) promiseRequestIdFilter.wrapIfNeeded(new MockHttpServletRequest()))); } -// @DataProvider -// public Object[][] msoMethods() { -// return Stream.<ThrowingConsumer<RestMsoImplementation>>of( -// -// client -> client.Get(new Object(), "/any path", new RestObject<>(), false), -// client -> client.GetForObject("/any path", Object.class), -// client -> client.Post("", "some payload", "/any path", new RestObject<>()), -// client -> client.PostForObject("some payload", "/any path", Object.class), -// client -> client.Put(Object.class, new RequestDetailsWrapper(), "/any path", new RestObject<>()) -// -// ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{}); -// } -// -// @Test(dataProvider = "msoMethods") -// public void mso(Consumer<RestMsoImplementation> f) throws Exception { -// final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation); -// -// f.accept(restMsoImplementation); -// -// Invocation.Builder fakeBuilder = mocks.getFakeBuilder(); -// Object requestIdValue = verifyXEcompRequestIdHeaderWasAdded(fakeBuilder); -// assertEquals(requestIdValue, captureHeaderKeyAndReturnItsValue(fakeBuilder, "X-ONAP-RequestID")); -// -// assertThat((String) captureHeaderKeyAndReturnItsValue(fakeBuilder, "Authorization"), startsWith("Basic ")); -// assertThat(captureHeaderKeyAndReturnItsValue(fakeBuilder, "X-ONAP-PartnerName"), equalTo("VID")); -// } -// -// @Test -// public void whenProvideMsoRestCallUserId_builderHasXRequestorIDHeader() throws Exception { -// -// final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation); -// String randomUserName = randomAlphabetic(10); -// -// restMsoImplementation.restCall(HttpMethod.DELETE, String.class, null, "abc", Optional.of(randomUserName)); -// assertEquals(randomUserName, captureHeaderKeyAndReturnItsValue(mocks.getFakeBuilder(), "X-RequestorID")); -// } + @DataProvider + public Object[][] msoMethods() { + return Stream.<ThrowingConsumer<RestMsoImplementation>>of( + client -> client.GetForObject("/any path", Object.class), + client -> client.restCall(HttpMethod.DELETE, Object.class, "some payload", "/any path", Optional.of("userId")), + client -> client.PostForObject("some payload", "/any path", Object.class) + ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{}); + } + + @Test(dataProvider = "msoMethods") + public void mso(Consumer<RestMsoImplementation> f) throws Exception { + final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation); + + f.accept(restMsoImplementation); + HeadersVerifier headersVerifier = new HeadersVerifier().verifyFirstCall(mocks.getFakeBuilder()); + + assertThat((String) captureHeaderKeyAndReturnItsValue(mocks.getFakeBuilder(), "Authorization"), startsWith("Basic ")); + + //verify requestId is same in next call but invocationId is different + + //given + final TestUtils.JavaxRsClientMocks mocks2 = setAndGetMocksInsideRestImpl(restMsoImplementation); + + //when + f.accept(restMsoImplementation); + //then + headersVerifier.verifySecondCall(mocks2.getFakeBuilder()); + } + + + + @Test + public void whenProvideMsoRestCallUserId_builderHasXRequestorIDHeader() throws Exception { + + final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation); + String randomUserName = randomAlphabetic(10); + + restMsoImplementation.restCall(HttpMethod.DELETE, String.class, null, "abc", Optional.of(randomUserName)); + assertEquals(randomUserName, captureHeaderKeyAndReturnItsValue(mocks.getFakeBuilder(), "X-RequestorID")); + } + + @DataProvider + public Object[][] msoRestClientNewMethods() { + return Stream.<ThrowingConsumer<MsoRestClientNew>>of( + client -> client.createInstance(new Object(), "/any path") + ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{}); + } + + @Test(dataProvider = "msoRestClientNewMethods") + public void msoRestClientNewHeadersTest(Consumer<MsoRestClientNew> f) throws Exception { + Map[] captor = setMocksForMsoRestClientNew(); + + f.accept(msoRestClientNew); + Map headers = captor[0]; + + String ecompRequestId = assertRequestHeaderIsUUID(headers, "X-ECOMP-RequestID"); + String onapRequestID = assertRequestHeaderIsUUID(headers, "X-ONAP-RequestID"); + assertEquals(ecompRequestId, onapRequestID); + + + String invocationId1 = assertRequestHeaderIsUUID(headers, "X-InvocationID"); + assertThat((String) headers.get("Authorization"), startsWith("Basic ")); + assertThat(headers.get("X-ONAP-PartnerName"), is("VID.VID")); + + //verify requestId is same in next call but invocationId is different + + //given + captor = setMocksForMsoRestClientNew(); + + //when + f.accept(msoRestClientNew); + headers = captor[0]; + + //then + assertEquals(headers.get("X-ONAP-RequestID"), onapRequestID); + String invocationId2 = assertRequestHeaderIsUUID(headers, "X-InvocationID"); + assertNotEquals(invocationId1, invocationId2); + + } + + private Map[] setMocksForMsoRestClientNew() { + reset(syncRestClient); + HttpResponse<String> httpResponse = mock(HttpResponse.class); + String expectedResponse = "myResponse"; + when(httpResponse.getStatus()).thenReturn(202); + when(httpResponse.getBody()).thenReturn(expectedResponse); + when(httpResponse.getRawBody()).thenReturn(toInputStream(expectedResponse, StandardCharsets.UTF_8)); + final Map[] headersCapture = new Map[1]; + when(syncRestClient.post(anyString(), anyMap(), any(), eq(String.class))).thenAnswer( + invocation -> { + headersCapture[0] = (Map)invocation.getArguments()[1]; + return httpResponse; + }); + + return headersCapture; + } @DataProvider public Object[][] aaiMethods() { return Stream.<ThrowingConsumer<AAIRestInterface>>of( client -> client.RestGet("from app id", "some transId", Unchecked.toURI("/any path"), false), - client -> client.Delete("whatever source id", "some transId", "/any path"), client -> client.RestPost("from app id", "/any path", "some payload", false), + client -> client.doRest("from app id", "some transId", Unchecked.toURI("/any path"), "somebody", HttpMethod.GET, false, true), client -> client.RestPut("from app id", "/any path", "some payload", false, false) ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{}); @@ -152,11 +253,21 @@ public class OutgoingRequestHeadersTest { @Test(dataProvider = "aaiMethods") public void aai(Consumer<AAIRestInterface> f) throws Exception { + //given final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(aaiRestInterface); + //when + f.accept(aaiRestInterface); + //then + HeadersVerifier headersVerifier = new HeadersVerifier().verifyFirstCall(mocks.getFakeBuilder()); + //verify requestId is same in next call but invocationId is different + //given + final TestUtils.JavaxRsClientMocks mocks2 = setAndGetMocksInsideRestImpl(aaiRestInterface); + //when f.accept(aaiRestInterface); + //then + headersVerifier.verifySecondCall(mocks2.getFakeBuilder()); - verifyXEcompRequestIdHeaderWasAdded(mocks.getFakeBuilder()); } // @Test(dataProvider = "schedulerMethods") @@ -169,14 +280,32 @@ public class OutgoingRequestHeadersTest { // // } - private Object verifyXEcompRequestIdHeaderWasAdded(Invocation.Builder fakeBuilder) { + private String verifyXEcompRequestIdHeaderWasAdded(Invocation.Builder fakeBuilder) { final String requestIdHeader = "x-ecomp-requestid"; - final String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; - Object requestId = captureHeaderKeyAndReturnItsValue(fakeBuilder, requestIdHeader); + return assertRequestHeaderIsUUID(fakeBuilder, requestIdHeader); + } + + private String assertRequestHeaderIsUUID(Invocation.Builder fakeBuilder, String headerName) { + Object headerValue = captureHeaderKeyAndReturnItsValue(fakeBuilder, headerName); + return assertRequestHeaderIsUUID(headerName, headerValue); + } + + private String assertRequestHeaderIsUUID(Map headers, String headerName) { + return assertRequestHeaderIsUUID(headerName, headers.get(headerName)); + } - assertThat("header '" + requestIdHeader + "' should be a uuid", requestId, + private String assertRequestHeaderIsUUID(String headerName, Object headerValue) { + final String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; + assertThat("header '" + headerName + "' should be a uuid", headerValue, allOf(instanceOf(String.class), hasToString(matchesPattern(uuidRegex)))); - return requestId; + return (String)headerValue; + } + + private void verifyXOnapPartnerNameHeaderWasAdded(Invocation.Builder fakeBuilder) { + assertThat( + captureHeaderKeyAndReturnItsValue(fakeBuilder, Headers.PARTNER_NAME.getHeaderName()), + is("VID.VID") + ); } private Object captureHeaderKeyAndReturnItsValue(Invocation.Builder fakeBuilder, String headerName) { @@ -187,22 +316,26 @@ public class OutgoingRequestHeadersTest { // The 'verify()' will capture the request id. If no match -- AssertionError will // catch for a second chance -- another 'verify()'. try { - ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class); - Mockito.verify(fakeBuilder) + try { + ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class); + Mockito.verify(fakeBuilder) .header( - Matchers.argThat(s -> equalsIgnoreCase(s, headerName)), - argumentCaptor.capture() + Matchers.argThat(s -> equalsIgnoreCase(s, headerName)), + argumentCaptor.capture() ); - requestId = argumentCaptor.getValue(); + requestId = argumentCaptor.getValue(); - } catch (AssertionError e) { - Mockito.verify(fakeBuilder).headers(multivaluedMapArgumentCaptor.capture()); + } catch (AssertionError e) { + Mockito.verify(fakeBuilder).headers(multivaluedMapArgumentCaptor.capture()); - final MultivaluedMap<String, Object> headersMap = multivaluedMapArgumentCaptor.getValue(); - final String thisRequestIdHeader = getFromSetCaseInsensitive(headersMap.keySet(), headerName); + final MultivaluedMap<String, Object> headersMap = multivaluedMapArgumentCaptor.getValue(); + final String thisRequestIdHeader = getFromSetCaseInsensitive(headersMap.keySet(), headerName); - assertThat(headersMap.keySet(), hasItem(thisRequestIdHeader)); - requestId = headersMap.getFirst(thisRequestIdHeader); + assertThat(headersMap.keySet(), hasItem(thisRequestIdHeader)); + requestId = headersMap.getFirst(thisRequestIdHeader); + } + } catch (AssertionError e) { + throw new AssertionError("header not captured: " + headerName, e); } return requestId; } @@ -246,4 +379,26 @@ public class OutgoingRequestHeadersTest { void acceptThrows(T t) throws Exception; } + private class HeadersVerifier { + + private String firstRequestId; + private String firstInvocationId; + + + HeadersVerifier verifyFirstCall(Builder fakeBuilder) { + firstRequestId = verifyXEcompRequestIdHeaderWasAdded(fakeBuilder); + assertEquals(firstRequestId, captureHeaderKeyAndReturnItsValue(fakeBuilder, "X-ONAP-RequestID")); + firstInvocationId = assertRequestHeaderIsUUID(fakeBuilder, "X-InvocationID"); + verifyXOnapPartnerNameHeaderWasAdded(fakeBuilder); + return this; + } + + void verifySecondCall(Builder fakeBuilder) { + String secondRequestId = verifyXEcompRequestIdHeaderWasAdded(fakeBuilder); + assertEquals(firstRequestId, secondRequestId); + + Object secondInvocationId = assertRequestHeaderIsUUID(fakeBuilder, "X-InvocationID"); + assertNotEquals(firstInvocationId, secondInvocationId); + } + } } diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java index 2eae1864f..9df99faa6 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java @@ -103,7 +103,6 @@ public class AaiServiceImplTest { private static final String SUBSCRIBER_ID = "SUBSCRIBER_ID_EXPECTED"; private static final String STATUS_TEXT = "STATUS_TEXT"; private static final String GLOBAL_SUBSCRIBER_ID = "GLOBAL_SUBSCRIBER_ID"; - private static final String GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE = "ID_NULL"; private static final String VNF_INSTANCE_ID_OK = "VNF_INSTANCE_ID_OK"; private static final String VNF_INSTANCE_ID_FAIL = "VNF_INSTANCE_ID_FAIL"; private static final String PARENT_NAME = "PARENT_NAME"; @@ -277,7 +276,7 @@ public class AaiServiceImplTest { } @Test - public void shouldGetVNFDataWithoutFiltering() { + public void shouldGetVNFDataOfInstanceWithoutFiltering() { when(aaiClient.getVNFData(anyString(), anyString(), anyString())).thenReturn(aaiResponse); AaiResponse actualResponse = aaiService.getVNFData(anyString(), anyString(), anyString()); @@ -286,30 +285,26 @@ public class AaiServiceImplTest { } @Test - public void shouldGetVNFDataWithFiltering() { + public void shouldGetVNFDataOfServiceWithoutFiltering() { VnfResult vnfResult1 = createVnfResult("ID1", "generic-vnf"); VnfResult vnfResult2 = createVnfResult("ID2", "service-instance"); VnfResult vnfResult3 = createVnfResult("ID3", "anything-else"); - List<VnfResult> vnfResults = Arrays.asList(vnfResult1, vnfResult2, vnfResult3); - AaiResponse<AaiGetVnfResponse> aaiResponseGetVnfResponse = createAaiResponseVnfResponse(vnfResults); - - vnfResults = Arrays.asList(vnfResult1, vnfResult2); - AaiResponse<AaiGetVnfResponse> expectedResponseWithReturnedVnfs = createAaiResponseVnfResponse(vnfResults); - AaiResponse expectedResponseWithoutReturnedVnfs = new AaiResponse(); + AaiResponse<AaiGetVnfResponse> aaiResponseGetVnfResponse = createAaiResponseVnfResponse( + Arrays.asList(vnfResult1, vnfResult2, vnfResult3)); when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)).thenReturn(aaiResponseGetVnfResponse); - when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE)).thenReturn(null); - AaiResponse<AaiGetVnfResponse> actualResponseWithReturnedVnfs = - aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE); - AaiResponse<AaiGetVnfResponse> actualResponseWithoutReturnedVnfs = - aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE); + assertThat(aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)) + .isEqualTo(aaiResponseGetVnfResponse); + } + + @Test + public void shouldGetNonNullVNFDataOfServiceWhenNoResult() { + when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)).thenReturn(null); - assertThat(actualResponseWithReturnedVnfs) - .isEqualToComparingFieldByFieldRecursively(expectedResponseWithReturnedVnfs); - assertThat(actualResponseWithoutReturnedVnfs) - .isEqualToComparingFieldByField(expectedResponseWithoutReturnedVnfs); + assertThat(aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)) + .isEqualToComparingFieldByField(new AaiResponse()); } @Test diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java index 92a55f0b8..6aa67051e 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java @@ -22,7 +22,6 @@ package org.onap.vid.services; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayWithSize; -import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -33,14 +32,11 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.vid.aai.AaiClientInterface; -import org.onap.vid.aai.AaiGetVnfResponse; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.model.AaiGetPnfResponse; import org.onap.vid.aai.model.AaiGetPnfs.Pnf; @@ -50,7 +46,6 @@ import org.onap.vid.aai.model.Relationship; import org.onap.vid.aai.model.RelationshipData; import org.onap.vid.aai.model.RelationshipList; import org.onap.vid.aai.model.ServiceRelationships; -import org.onap.vid.aai.model.VnfResult; import org.onap.vid.model.aaiTree.AAITreeNode; import org.onap.vid.roles.Role; import org.onap.vid.roles.RoleValidator; @@ -211,20 +206,4 @@ public class AaiServiceTest { assertThat(anyMatch, equalTo(expectedMatch)); } - @Test - public void testFilterChangeManagementVNFCandidatesResponse() { - AaiGetVnfResponse aaiGetVnfResponse = new AaiGetVnfResponse(); - aaiGetVnfResponse.results = new ArrayList<>(); - Stream.of("genEric-vNf", "l3-interface-ipv6-address-list", "vserver", "pserver", "serviCe-inStance").forEach( - nodeType->{ - VnfResult vnfResult = new VnfResult(); - vnfResult.nodeType=nodeType; - aaiGetVnfResponse.results.add(vnfResult); - } - ); - - AaiResponse<AaiGetVnfResponse> result = aaiService.filterChangeManagementVNFCandidatesResponse(new AaiResponse<>(aaiGetVnfResponse, "", 200)); - assertEquals(2, result.getT().results.size()); - assertThat(result.getT().results.stream().map(x->x.nodeType).collect(Collectors.toList()), containsInAnyOrder("genEric-vNf","serviCe-inStance")); - } } diff --git a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java index 40546e967..20c9d1443 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java @@ -21,8 +21,52 @@ package org.onap.vid.services; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.stream.Collectors.toList; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.both; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.mockito.Mockito.when; +import static org.onap.vid.job.Job.JobStatus.COMPLETED; +import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_ERRORS; +import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_NO_ACTION; +import static org.onap.vid.job.Job.JobStatus.CREATING; +import static org.onap.vid.job.Job.JobStatus.FAILED; +import static org.onap.vid.job.Job.JobStatus.IN_PROGRESS; +import static org.onap.vid.job.Job.JobStatus.PAUSE; +import static org.onap.vid.job.Job.JobStatus.PENDING; +import static org.onap.vid.job.Job.JobStatus.PENDING_RESOURCE; +import static org.onap.vid.job.Job.JobStatus.RESOURCE_IN_PROGRESS; +import static org.onap.vid.job.Job.JobStatus.STOPPED; +import static org.onap.vid.testUtils.TestUtils.generateRandomAlphaNumeric; +import static org.onap.vid.utils.Streams.not; +import static org.testng.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import java.lang.reflect.Method; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentSkipListSet; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; +import javax.inject.Inject; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; @@ -37,20 +81,21 @@ import org.mockito.MockitoAnnotations; import org.onap.portalsdk.core.domain.support.DomainVo; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.vid.config.DataSourceConfig; +import org.onap.vid.config.JobAdapterConfig; import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.exceptions.OperationNotAllowedException; import org.onap.vid.job.Job; import org.onap.vid.job.JobAdapter; +import org.onap.vid.job.JobAdapter.AsyncJobRequest; import org.onap.vid.job.JobType; import org.onap.vid.job.JobsBrokerService; import org.onap.vid.job.command.JobCommandFactoryTest; import org.onap.vid.job.impl.JobDaoImpl; import org.onap.vid.job.impl.JobSchedulerInitializer; +import org.onap.vid.job.impl.JobSharedData; import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl; -import org.onap.vid.services.VersionService; import org.onap.vid.utils.DaoUtils; -import org.onap.vid.config.DataSourceConfig; -import org.onap.vid.config.JobAdapterConfig; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.Assert; @@ -59,31 +104,6 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import javax.inject.Inject; -import java.lang.reflect.Method; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; -import java.util.concurrent.*; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; - -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static java.util.stream.Collectors.toList; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.both; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.mockito.Mockito.when; -import static org.onap.vid.job.Job.JobStatus.*; -import static org.onap.vid.utils.Streams.not; -import static org.onap.vid.testUtils.TestUtils.generateRandomAlphaNumeric; -import static org.testng.Assert.assertNotNull; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; - @ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, JobAdapterConfig.class}) public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { @@ -944,4 +964,40 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { broker.delete(new UUID(111, 111)); } + public static class MockAsyncRequest implements AsyncJobRequest { + public String value; + + public MockAsyncRequest() {} + + public MockAsyncRequest(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + @Test + public void twoJobsWithSamePosition_bothJobsArePulled(){ + UUID uuid = UUID.randomUUID(); + int positionInBulk = RandomUtils.nextInt(); + String userId = "userId"; + + Optional<Job> firstPulledJob = createAddAndPullJob(uuid, positionInBulk, userId, "first value"); + Optional<Job> secondPulledJob = createAddAndPullJob(uuid, positionInBulk, userId, "second value"); + + MockAsyncRequest firstValue = (MockAsyncRequest) firstPulledJob.get().getSharedData().getRequest(); + MockAsyncRequest secondValue = (MockAsyncRequest) secondPulledJob.get().getSharedData().getRequest(); + assertThat(ImmutableList.of(firstValue.value, secondValue.value), + containsInAnyOrder("first value", "second value")); + } + + private Optional<Job> createAddAndPullJob(UUID uuid, int positionInBulk, String userId, String s) { + JobDaoImpl job1 = createNewJob(positionInBulk, uuid, userId, CREATING, null, + LocalDateTime.now().minusSeconds(1), false); + job1.setSharedData(new JobSharedData(null, userId, new MockAsyncRequest(s), "testApi")); + broker.add(job1); + return broker.pull(CREATING, userId); + } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java index 8ad111849..2bc664591 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java @@ -1,12 +1,10 @@ package org.onap.simulator.presetGenerator.presets.BasePresets; -import vid.automation.test.infra.Features; +import static org.apache.commons.lang3.StringUtils.isNotEmpty; import java.util.Map; +import vid.automation.test.infra.Features; -/** - * Created by itzikliderman on 27/12/2017. - */ public abstract class BaseMSOPreset extends BasePreset { public static final String DEFAULT_CLOUD_OWNER = "irma-aic"; @@ -31,14 +29,14 @@ public abstract class BaseMSOPreset extends BasePreset { protected String addCloudOwnerIfNeeded() { return Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST.isActive() ? - "\"cloudOwner\": \""+cloudOwner+"\"," : ""; + "\"cloudOwner\": \"" + cloudOwner + "\"," : ""; } protected String addPlatformIfNeeded(String platform) { - return platform != "" ? - " \"platform\": {" + - " \"platformName\": \""+platform+"\"," + - "}," : ""; + return isNotEmpty(platform) ? + " \"platform\": {" + + " \"platformName\": \"" + platform + "\"," + + "}," : ""; } @Override @@ -49,7 +47,7 @@ public abstract class BaseMSOPreset extends BasePreset { @Override public Map<String, String> getRequestHeaders() { Map<String, String> map = super.getRequestHeaders(); - map.put("X-ONAP-PartnerName", "VID"); + map.put("X-ONAP-PartnerName", "VID.VID"); return map; } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseSDCPreset.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseSDCPreset.java index d5f8b84cd..ad8dfb3ac 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseSDCPreset.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseSDCPreset.java @@ -1,12 +1,19 @@ package org.onap.simulator.presetGenerator.presets.BasePresets; -/** - * Created by itzikliderman on 27/12/2017. - */ +import java.util.Map; + public abstract class BaseSDCPreset extends BasePreset { @Override protected String getRootPath() { return "/sdc/v1/catalog/services"; } + + @Override + public Map<String, String> getRequestHeaders() { + Map<String, String> map = super.getRequestHeaders(); + map.put("X-ONAP-PartnerName", "VID.VID"); + return map; + } + } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java index 0808eaba6..575a8888e 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java @@ -1,5 +1,6 @@ package org.onap.simulator.presetGenerator.presets.aai; +import org.apache.commons.lang3.StringUtils; import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; import org.springframework.http.HttpMethod; @@ -9,21 +10,46 @@ public class PresetAAIGetTenants extends BaseAAIPreset { private final String subscriberId; private final String serviceType; private String responseBody; + private static final String responseBodyResourceDefault = "presets_templates/PresetAAIGetTenants.json"; public PresetAAIGetTenants(String subscriberId, String serviceType, String responseBodyResource) { this.subscriberId = subscriberId; this.serviceType = serviceType; - this.responseBody = loadResourceAsString(responseBodyResource); + this.responseBody = loadResponseBody(responseBodyResource); } public PresetAAIGetTenants() { this( - "e433710f-9217-458d-a79d-1c7aff376d89", - "TYLER SILVIA", - "presets_templates/PresetAAIGetTenants.json" + "e433710f-9217-458d-a79d-1c7aff376d89", + "TYLER SILVIA", + responseBodyResourceDefault ); } + public PresetAAIGetTenants(String subscriberId, String serviceType) { + this( + subscriberId, + serviceType, + responseBodyResourceDefault + ); + } + + private String loadResponseBody(String responseBodyResource) { + + String responseBody = loadResourceAsString(responseBodyResource); + + if (StringUtils.equals(responseBodyResource, responseBodyResourceDefault)) { + responseBody = setServiceTypeInTheResponse(responseBody); + } + + return responseBody; + } + + private String setServiceTypeInTheResponse(String resourceBodyAsString) { + final String serviceTypePlaceHolder = "<service-type>"; + return resourceBodyAsString.replace(serviceTypePlaceHolder, this.serviceType); + } + @Override public Object getResponseBody() { return responseBody; @@ -38,6 +64,4 @@ public class PresetAAIGetTenants extends BaseAAIPreset { public String getReqPath() { return getRootPath() + "/business/customers/customer/" + this.subscriberId + "/service-subscriptions/service-subscription/" + this.serviceType; } - - } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceDesignAndCreationPut.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceDesignAndCreationPut.java index 180685282..5ffd24253 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceDesignAndCreationPut.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceDesignAndCreationPut.java @@ -208,6 +208,7 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { " {" + " \"model-version-id\": \"0903e1c0-8e03-4936-b5c2-260653b96413\"," + " \"model-name\": \"action-data\"," + + " \"orchestration-type\": \"a la carte\"," + " \"model-version\": \"1.0\"," + " \"model-description\": \"honor immunity exile prong below misshapen\"," + " \"resource-version\": \"4076846985447\"" + @@ -226,6 +227,7 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { " {" + " \"model-version-id\": \"666a06ee-4b57-46df-bacf-908da8f10c3f\"," + " \"model-name\": \"multicast-configuration\"," + + " \"orchestration-type\": \"a la carte\"," + " \"model-version\": \"1.0\"," + " \"model-description\": \"python bullwhip appointment computation ambidextrous heaving\"," + " \"resource-version\": \"1500136282691\"" + @@ -244,6 +246,7 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { " {" + " \"model-version-id\": \"20c4431c-246d-11e7-93ae-92361f002671\"," + " \"model-name\": \"vSAMP10aDEV::base::module-0\"," + + " \"orchestration-type\": \"a la carte\"," + " \"model-version\": \"2\"," + " \"model-description\": \"MSO aLaCarte VF vSAMP10aDEV Base\"," + " \"resource-version\": \"1492627634300\"" + @@ -262,6 +265,7 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { " {" + " \"model-version-id\": \"797a6c41-0f80-4d35-a288-3920c4e06baa\"," + " \"model-name\": \"CONTRAIL30_L2NODHCP\"," + + " \"orchestration-type\": \"macro\"," + " \"model-version\": \"1.0\"," + " \"model-description\": \"contrail 3.0.x L2 network for AIC 3.x sites (and No DHCP).\"," + " \"resource-version\": \"1492814035003\"," + @@ -307,6 +311,7 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { " {" + " \"model-version-id\": \"f1bde010-cc5f-4765-941f-75f15b24f9fc\"," + " \"model-name\": \"BkVmxAv061917..base_vPE_AV..module-0\"," + + " \"orchestration-type\": \"macro\"," + " \"model-version\": \"2\"," + " \"resource-version\": \"1497897268769\"," + " \"relationship-list\": {" + @@ -351,6 +356,7 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { " {" + " \"model-version-id\": \"ipe-resource-id-ps-02\"," + " \"model-name\": \"abc\"," + + " \"orchestration-type\": \"macro\"," + " \"model-version\": \"v1.0\"," + " \"resource-version\": \"1493389520357\"," + " \"relationship-list\": {" + @@ -395,6 +401,7 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { " {" + " \"model-version-id\": \"lmoser410-connector-model-version-id\"," + " \"model-name\": \"connector\"," + + " \"orchestration-type\": \"macro\"," + " \"model-version\": \"v1.0\"," + " \"resource-version\": \"1493389444766\"" + " }" + diff --git a/vid-automation/src/main/java/vid/automation/test/infra/Features.java b/vid-automation/src/main/java/vid/automation/test/infra/Features.java index 6a15d8961..312c3fd99 100644 --- a/vid-automation/src/main/java/vid/automation/test/infra/Features.java +++ b/vid-automation/src/main/java/vid/automation/test/infra/Features.java @@ -50,6 +50,7 @@ public enum Features implements Feature { FLAG_PNP_INSTANTIATION, FLAG_HANDLE_SO_WORKFLOWS, FLAG_CREATE_ERROR_REPORTS, + FLAG_SHOW_ORCHESTRATION_TYPE, FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT, FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG, FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH, diff --git a/vid-automation/src/main/java/vid/automation/test/sections/BrowseASDCPage.java b/vid-automation/src/main/java/vid/automation/test/sections/BrowseASDCPage.java index febbe6e83..de69e0047 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/BrowseASDCPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/BrowseASDCPage.java @@ -37,7 +37,7 @@ public class BrowseASDCPage extends VidBasePage { } public int countCurrentRowsInTable(){ - List<WebElement> rowsInTable = Get.byClass("alt-row"); + List<WebElement> rowsInTable = Get.byClass("sdcServiceModel"); return rowsInTable.size(); } diff --git a/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java b/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java index 7290204d6..43dd68f06 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java @@ -4,10 +4,7 @@ import com.aventstack.extentreports.Status; import org.junit.Assert; import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions; import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; +import org.openqa.selenium.*; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import vid.automation.test.Constants; @@ -113,6 +110,17 @@ public class VidBasePage { return this; } + public boolean isModelWithGivenServiceUUIDVisible(String serviceUUID) { + String elementTestId = Constants.DEPLOY_BUTTON_TESTS_ID_PREFIX + serviceUUID; + try { + GeneralUIUtils.getWebElementByTestID(elementTestId, 10); + GeneralUIUtils.ultimateWait(); + } catch (TimeoutException te) { + return false; + } + return true; + } + public void screenshotDeployDialog(String serviceUUID) { try { GeneralUIUtils.ultimateWait(); diff --git a/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java b/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java index f082044fd..eb08c1f2a 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java @@ -31,8 +31,9 @@ import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; -import static vid.automation.test.infra.Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI; import static vid.automation.test.infra.Features.FLAG_5G_IN_NEW_INSTANTIATION_UI; +import static vid.automation.test.infra.Features.FLAG_SHOW_ORCHESTRATION_TYPE; +import static vid.automation.test.infra.Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI; import static vid.automation.test.infra.ModelInfo.*; @@ -479,4 +480,39 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { assertFalse(Exists.tagNameInAnotherElement(serviceModelsTbody, "tr"), "Table should be empty on empty results"); resetGetServicesCache(); } + + private static final String[] macroModelsIds = { + "f1bde010-cc5f-4765-941f-75f15b24f9fc", + "lmoser410-connector-model-version-id", + "ipe-resource-id-ps-02", + "797a6c41-0f80-4d35-a288-3920c4e06baa", + }; + private static final String[] alacarteModelsIds = { + "0903e1c0-8e03-4936-b5c2-260653b96413", + "666a06ee-4b57-46df-bacf-908da8f10c3f", + "20c4431c-246d-11e7-93ae-92361f002671", + }; + + @DataProvider + public static Object[][] filterOrchestrationType() { + return new Object[][]{{"a la carte", 3, alacarteModelsIds},{"macro", 4, macroModelsIds}}; + } + + @Test(dataProvider = "filterOrchestrationType") + @FeatureTogglingTest(FLAG_SHOW_ORCHESTRATION_TYPE) + public void browseSdcModel_filterModelsWithOrchestrationType_alacarte( + String orchestrationType,int numberOfOccurrence, String[] expectedModelsIds) { + resetGetServicesCache(); + SimulatorApi.clearAll(); + BrowseASDCPage browseAsdcPage = registerSimulatorAndGoToBrowseSDC(); + GeneralUIUtils.ultimateWait(); + assertThat(browseAsdcPage.countCurrentRowsInTable(),(Matchers.greaterThan(numberOfOccurrence))); + browseAsdcPage.fillFilterText(orchestrationType); + Assert.assertEquals(browseAsdcPage.countCurrentRowsInTable(),numberOfOccurrence); + for(String id : expectedModelsIds) { + Assert.assertTrue(browseAsdcPage.isModelWithGivenServiceUUIDVisible(id)); + } + browseAsdcPage.fillFilterText(""); + } + } diff --git a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java index 7c577cabf..d9c771b6f 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java @@ -23,6 +23,7 @@ import com.aventstack.extentreports.Status; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.primitives.Ints; + import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; @@ -33,6 +34,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; + import net.javacrumbs.jsonunit.core.Option; import org.json.JSONException; import org.junit.Assert; @@ -223,7 +225,7 @@ public class ChangeManagementTest extends VidBaseTestCase { , "changeManagement/mso_get_change_managements_scaleout.json" ); SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), APPEND); - if(FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG.isActive()){ + if (FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG.isActive()) { String AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS = "registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_with_modelVer.json"; String globalCustomerId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"; String serviceType = "vRichardson"; @@ -246,9 +248,9 @@ public class ChangeManagementTest extends VidBaseTestCase { if (Features.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH.isActive()) { SimulatorApi.registerExpectationFromPreset(new PresetAAIGetTenants( - VNF_DATA_WITH_IN_PLACE.subscriberId, - VNF_DATA_WITH_IN_PLACE.serviceType, - "presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json"), SimulatorApi.RegistrationStrategy.APPEND); + VNF_DATA_WITH_IN_PLACE.subscriberId, + VNF_DATA_WITH_IN_PLACE.serviceType), + SimulatorApi.RegistrationStrategy.APPEND); } diff --git a/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants.json b/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants.json index 039d2d558..c3eca2e0a 100644 --- a/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants.json +++ b/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants.json @@ -1,5 +1,5 @@ { - "service-type": "TYLER SILVIA", + "service-type": "<service-type>", "resource-version": "1494001841964", "relationship-list": { "relationship": [ diff --git a/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json b/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json deleted file mode 100644 index 8cd6d19a7..000000000 --- a/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "service-type": "vWINIFRED", - "resource-version": "1494001841964", - "relationship-list": { - "relationship": [ - { - "related-to": "tenant", - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/AAIAIC25/tenants/tenant/092eb9e8e4b7412e8787dd091bc58e86", - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "irma-aic" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "AAIAIC25" - }, - { - "relationship-key": "tenant.tenant-id", - "relationship-value": "092eb9e8e4b7412e8787dd091bc58e86" - } - ], - "related-to-property": [ - { - "property-key": "tenant.tenant-name", - "property-value": "USP-SIP-IC-24335-T-01" - } - ] - }, - { - "related-to": "tenant", - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/tenants/tenant/bae71557c5bb4d5aac6743a4e5f1d054", - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "irma-aic" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "hvf6" - }, - { - "relationship-key": "tenant.tenant-id", - "relationship-value": "bae71557c5bb4d5aac6743a4e5f1d054" - } - ], - "related-to-property": [ - { - "property-key": "tenant.tenant-name", - "property-value": "AIN Web Tool-15-D-testalexandria" - } - ] - }, - { - "related-to": "tenant", - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/tenants/tenant/229bcdc6eaeb4ca59d55221141d01f8e", - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "irma-aic" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "hvf6" - }, - { - "relationship-key": "tenant.tenant-id", - "relationship-value": "229bcdc6eaeb4ca59d55221141d01f8e" - } - ], - "related-to-property": [ - { - "property-key": "tenant.tenant-name", - "property-value": "AIN Web Tool-15-D-STTest2" - } - ] - }, - { - "related-to": "tenant", - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/tenants/tenant/cb42a77ff45b48a8b8deb83bb64acc74", - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "irma-aic" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "hvf6" - }, - { - "relationship-key": "tenant.tenant-id", - "relationship-value": "cb42a77ff45b48a8b8deb83bb64acc74" - } - ], - "related-to-property": [ - { - "property-key": "tenant.tenant-name", - "property-value": "ro-T11" - } - ] - }, - { - "related-to": "tenant", - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/tenants/tenant/fa45ca53c80b492fa8be5477cd84fc2b", - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "irma-aic" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "hvf6" - }, - { - "relationship-key": "tenant.tenant-id", - "relationship-value": "fa45ca53c80b492fa8be5477cd84fc2b" - } - ], - "related-to-property": [ - { - "property-key": "tenant.tenant-name", - "property-value": "ro-T112" - } - ] - } - ] - } -} diff --git a/vid-automation/src/main/resources/registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_response.json b/vid-automation/src/main/resources/registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_response.json index 258cd0e1a..5ee78f308 100644 --- a/vid-automation/src/main/resources/registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_response.json +++ b/vid-automation/src/main/resources/registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_response.json @@ -51,6 +51,38 @@ ] }, { + "id": "454760", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v13/network/generic-vnfs/generic-vnf/a9c90905-99f2-45d5-8389-a2e0f6997c25/vf-modules/vf-module/98da0cd7-008a-4935-864e-333bb97bd15a", + "properties": { + "vf-module-id": "98da0cd7-008a-4935-864e-333bb97bd15a", + "vf-module-name": "ws-vnf", + "heat-stack-id": "ws-vnf/ba8955da-912d-4aa7-8bbe-ff51025f56fe", + "orchestration-status": "active", + "is-base-vf-module": true, + "automated-assignment": false, + "resource-version": "1551709026933", + "model-invariant-id": "4c6d21f0-dc36-46e7-ba9e-c8b602054d12", + "model-version-id": "0040b766-37e8-42e7-a930-bfc568265735", + "model-customization-id": "1cb1464c-4bf2-4910-8eac-e7d27b597d58", + "module-index": 0 + }, + "related-to": [ + { + "id": "442472", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "node-type": "generic-vnf", + "url": "/aai/v13/network/generic-vnfs/generic-vnf/a9c90905-99f2-45d5-8389-a2e0f6997c25" + }, + { + "id": "430168", + "relationship-label": "org.onap.relationships.inventory.Uses", + "node-type": "vserver", + "url": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/982c540f6e69488eb6be5664255e00c0/vservers/vserver/154e8975-5a59-4824-af5d-b6564b7b712a" + } + ] + }, + { "id": "3775807704", "node-type": "service-instance", "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/9ad4ac55-a5e0-4b49-95c0-b2d846abf700", diff --git a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java index 69267fd4d..4ca01dc63 100644 --- a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java +++ b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java @@ -3,7 +3,6 @@ package org.onap.vid.api; import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNot.not; import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.defaultPlacement; import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofL3Network; import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofServiceInstance; @@ -99,6 +98,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + + " \"orchestrationType\": null,\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + " }, {\n" + @@ -112,6 +112,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_ERROR\",\n" + + " \"orchestrationType\": null,\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + " }, {\n" + @@ -124,6 +125,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lifecycleState\": null,\n" + " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + + " \"orchestrationType\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + @@ -138,6 +140,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + + " \"orchestrationType\": null,\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + " }, {\n" + @@ -151,6 +154,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + + " \"orchestrationType\": null,\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + " }, {\n" + @@ -163,6 +167,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lifecycleState\": null,\n" + " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + + " \"orchestrationType\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + @@ -176,6 +181,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lifecycleState\": null,\n" + " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + + " \"orchestrationType\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + @@ -189,6 +195,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lifecycleState\": null,\n" + " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + + " \"orchestrationType\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + @@ -202,6 +209,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lifecycleState\": null,\n" + " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + + " \"orchestrationType\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + @@ -215,6 +223,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lifecycleState\": null,\n" + " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + + " \"orchestrationType\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + @@ -228,6 +237,7 @@ public class AaiApiTest extends BaseApiAaiTest { " \"lifecycleState\": null,\n" + " \"lastUpdaterUserId\": null,\n" + " \"lastUpdaterFullName\": null,\n" + + " \"orchestrationType\": null,\n" + " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" + " \"artifacts\": null,\n" + " \"resources\": null\n" + @@ -730,6 +740,7 @@ public class AaiApiTest extends BaseApiAaiTest { getResourceAsString("serviceWithNetwork/aaiGetNetworksWithVlansToVnfByServiceInstance.json"), response); } + @FeatureTogglingTest(value = Features.FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG, flagActive = false) @Test public void getVnfDataByGlobalIdAndServiceType() { @@ -750,9 +761,8 @@ public class AaiApiTest extends BaseApiAaiTest { ResponseEntity<String> response = restTemplate.getForEntity(url, String.class); - assertThat(response.getBody(), not(containsString("generic-vfmodule"))); assertResponse(JsonAssert.when(Option.IGNORING_ARRAY_ORDER), - getResourceAsString("changeManagement/reduced_vnf_data_by_globalid_and_service_type.json"), + getResourceAsString("registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_response.json"), response.getBody()); } diff --git a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java index 3ec0c16e4..e01ffe8b4 100644 --- a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java +++ b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java @@ -1,9 +1,8 @@ package org.onap.vid.more; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.junit.Assert.assertThat; import com.fasterxml.jackson.databind.JsonNode; import java.net.URI; @@ -41,6 +40,11 @@ public class LoggerFormatTest extends BaseApiTest { validateLogsFormat("audit"); } + @Test + public void validateAudit2019LogsFormat() { + validateLogsFormat("audit2019", "audit-ELS-2019.11", 0); + } + @Test(enabled = false) // no total-score is returned for error-log public void validateErrorLogsFormat() { validateLogsFormat("error"); @@ -57,6 +61,10 @@ public class LoggerFormatTest extends BaseApiTest { } private void validateLogsFormat(String logName, String logType) { + validateLogsFormat(logName, logType, 0.95); + } + + private void validateLogsFormat(String logName, String logType, double score) { String logLines = getLogLines(logName); logger.info("logLines are: "+logLines); @@ -65,8 +73,8 @@ public class LoggerFormatTest extends BaseApiTest { double fieldscore = response.path("summary").path("score").path("fieldscore").asDouble(); double overall = response.path("summary").path("score").path("overallscore").asDouble(); - assertThat(fieldscore, is(greaterThan(0.95))); - assertThat(overall, is(greaterThan(0.95))); + assertThat(fieldscore, is(greaterThanOrEqualTo(score))); + assertThat(overall, is(greaterThanOrEqualTo(score))); } diff --git a/vid-automation/src/test/resources/changeManagement/reduced_vnf_data_by_globalid_and_service_type.json b/vid-automation/src/test/resources/changeManagement/reduced_vnf_data_by_globalid_and_service_type.json deleted file mode 100644 index 1f6a5eb2c..000000000 --- a/vid-automation/src/test/resources/changeManagement/reduced_vnf_data_by_globalid_and_service_type.json +++ /dev/null @@ -1,539 +0,0 @@ -{ - "results": [ - { - "id": "3400916992", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/66b13cb4-b575-449f-aa45-ffbfe005c7b1", - "properties": { - "service-instance-id": "66b13cb4-b575-449f-aa45-ffbfe005c7b1", - "service-instance-name": "CHARLOTTE_preload_1710_0914", - "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", - "model-version-id": "1525f534-99a2-408f-b847-ff636997d352", - "resource-version": "1505856078810", - "orchestration-status": "Active" - }, - "related-to": [ - { - "id": "10207440", - "node-type": "service-subscription", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" - }, - { - "id": "3481829392", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec" - } - ] - }, - { - "id": "3771572432", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/f195837b-ef28-42c3-8dea-47ad37eaed95", - "properties": { - "service-instance-id": "f195837b-ef28-42c3-8dea-47ad37eaed95", - "service-instance-name": "CHARLOTTE_preload_1710_0914_0920", - "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", - "model-version-id": "3915de55-a904-4cc6-8fc3-86f8bc316616", - "resource-version": "1505964829466", - "orchestration-status": "Active" - }, - "related-to": [ - { - "id": "10207440", - "node-type": "service-subscription", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" - }, - { - "id": "3484520464", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1" - } - ] - }, - { - "id": "3775807704", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/9ad4ac55-a5e0-4b49-95c0-b2d846abf700", - "properties": { - "service-instance-id": "9ad4ac55-a5e0-4b49-95c0-b2d846abf700", - "service-instance-name": "CHARLOTTE_preload_1710_0914_100417", - "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", - "model-version-id": "3915de55-a904-4cc6-8fc3-86f8bc316616", - "resource-version": "1507144734087", - "orchestration-status": "Active" - }, - "related-to": [ - { - "id": "10207440", - "node-type": "service-subscription", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" - }, - { - "id": "3783459064", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/54626a59-ec0d-4fa9-b0c2-08d008688165" - } - ] - }, - { - "id": "4178862184", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/599c7247-b083-447c-b6b1-0cdd5170dfd2", - "properties": { - "service-instance-id": "599c7247-b083-447c-b6b1-0cdd5170dfd2", - "service-instance-name": "CHARLOTTE_preload_1710_0914_1010", - "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", - "model-version-id": "3915de55-a904-4cc6-8fc3-86f8bc316616", - "resource-version": "1507664240411", - "orchestration-status": "Active" - }, - "related-to": [ - { - "id": "10207440", - "node-type": "service-subscription", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" - }, - { - "id": "3892133896", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/d74503d8-abab-49c6-ba48-a6211eee9b7a" - } - ] - }, - { - "id": "3008335920", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08", - "properties": { - "service-instance-id": "97315a05-e6f3-4c47-ae7e-d850c327aa08", - "service-instance-name": "CHARLOTTE_preload_1710_0914_0927", - "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", - "model-version-id": "3915de55-a904-4cc6-8fc3-86f8bc316616", - "resource-version": "1506527653053", - "orchestration-status": "Active" - }, - "related-to": [ - { - "id": "10207440", - "node-type": "service-subscription", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" - }, - { - "id": "3418898432", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855" - } - ] - }, - { - "id": "3481829392", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec", - "properties": { - "vnf-id": "0c465dd3-4151-4da9-92a2-541bb3174cec", - "vnf-name": "Eoghan Fausto", - "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "PREPROV", - "orchestration-status": "Created", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1505856137206", - "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "model-version-id": "afacccf6-397d-45d6-b5ae-94c39734b168", - "model-customization-id": "b54689f8-45c5-4be2-9e91-f033e028feec", - "nf-type": "DNS", - "nf-function": "Mobile DNS", - "nf-role": "vWheeler", - "nf-naming-code": "null" - }, - "related-to": [ - { - "id": "3285635208", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec/vf-modules/vf-module/d49713bf-1bff-4eab-bed1-a8f1bb83aa98" - }, - { - "id": "3441209432", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec/vf-modules/vf-module/b8397fec-cf13-40b3-be8f-7d0912506419" - }, - { - "id": "3687522312", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec/vf-modules/vf-module/fd098a52-09be-4c48-a9e9-a565d1b39db3" - }, - { - "id": "3400916992", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/66b13cb4-b575-449f-aa45-ffbfe005c7b1" - }, - { - "id": "3477385312", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" - } - ] - }, - { - "id": "3484520464", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1", - "properties": { - "vnf-id": "c2d2d389-fa00-4fb4-a269-e46d495719e1", - "vnf-name": "Odell Romana", - "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "PREPROV", - "orchestration-status": "Created", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1505964996823", - "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "model-version-id": "76e908e0-5201-44d2-a3e2-9e6128d05820", - "model-customization-id": "c00e8fc8-af39-4da8-8c78-a7efc2fe5994", - "nf-type": "DNS", - "nf-function": "Mobile DNS", - "nf-role": "vMobileDNS", - "nf-naming-code": "null" - }, - "related-to": [ - { - "id": "3447107680", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/c4711b5c-742e-4d03-8146-bff763f69fbd" - }, - { - "id": "3448307712", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/0ba3fcdd-0536-4ac7-a9ec-8d8622db7fb2" - }, - { - "id": "3692179528", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/6bb843eb-ef84-43b1-83b4-3154a7f9928c" - }, - { - "id": "3771588816", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/a4c008c6-cac0-4e3f-928f-90fa37dc8c4b" - }, - { - "id": "3904077944", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/eecb619c-a173-4ead-bf48-d4d09cbbdd5e" - }, - { - "id": "4027855088", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/1e29424e-2dca-45ac-b1df-59a8f74d0bc1" - }, - { - "id": "4390871192", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/b185220a-7f63-4b29-867d-1452813a4f09" - }, - { - "id": "4450529432", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/7a0c4b98-b3cc-490c-bbab-e2d7f169f2d7" - }, - { - "id": "3771572432", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/f195837b-ef28-42c3-8dea-47ad37eaed95" - } - ] - }, - { - "id": "3783459064", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/54626a59-ec0d-4fa9-b0c2-08d008688165", - "properties": { - "vnf-id": "54626a59-ec0d-4fa9-b0c2-08d008688165", - "vnf-name": "Dominika Fionnbharr", - "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "PREPROV", - "orchestration-status": "Created", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1507144948937", - "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "model-version-id": "76e908e0-5201-44d2-a3e2-9e6128d05820", - "model-customization-id": "c00e8fc8-af39-4da8-8c78-a7efc2fe5994", - "nf-type": "DNS", - "nf-function": "Mobile DNS", - "nf-role": "vMobileDNS", - "nf-naming-code": "null" - }, - "related-to": [ - { - "id": "3775807704", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/9ad4ac55-a5e0-4b49-95c0-b2d846abf700" - } - ] - }, - { - "id": "3892133896", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/d74503d8-abab-49c6-ba48-a6211eee9b7a", - "properties": { - "vnf-id": "d74503d8-abab-49c6-ba48-a6211eee9b7a", - "vnf-name": "CHARLOTTE_PreloadTest_VNF", - "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "PREPROV", - "orchestration-status": "Created", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1507664288548", - "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "model-version-id": "76e908e0-5201-44d2-a3e2-9e6128d05820", - "model-customization-id": "c00e8fc8-af39-4da8-8c78-a7efc2fe5994", - "nf-type": "DNS", - "nf-function": "Mobile DNS", - "nf-role": "vMobileDNS", - "nf-naming-code": "null" - }, - "related-to": [ - { - "id": "4178862184", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/599c7247-b083-447c-b6b1-0cdd5170dfd2" - } - ] - }, - { - "id": "1507690314", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/385548e2-3f31-4900-9437-317d0346e49a", - "properties": { - "vnf-id": "385548e2-3f31-4900-9437-317d0346e49a", - "vnf-name": "Senga Gabrielle", - "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "PREPROV", - "orchestration-status": "Created", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "7788675952902", - "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "model-version-id": "b217c612-7fcf-484c-861b-df0a5c4b5bcb", - "model-customization-id": "ce15d245-763c-4079-ac82-fe93007adb69", - "nf-type": "DNS", - "nf-function": "Mobile DNS", - "nf-role": "vMobileDNS", - "nf-naming-code": "null" - }, - "related-to": [ - { - "id": "3664617648", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855/vf-modules/vf-module/788cde64-c288-4971-8e8c-77973c5009dc" - }, - { - "id": "3008335920", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08" - }, - { - "id": "3477385312", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" - } - ] - }, - { - "id": "5278880615", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0465e048-92a4-4a7f-bfe7-de39b32de4bd", - "properties": { - "vnf-id": "0465e048-92a4-4a7f-bfe7-de39b32de4bd", - "vnf-name": "Constantius Raghu", - "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "PREPROV", - "orchestration-status": "Created", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "7788675952902", - "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "model-version-id": "afacccf6-397d-45d6-b5ae-94c39734b168", - "model-customization-id": "ce15d245-763c-4079-ac82-fe93007adb69", - "nf-type": "DNS", - "nf-function": "Mobile DNS", - "nf-role": "vWheeler", - "nf-naming-code": "null" - }, - "related-to": [ - { - "id": "3664617648", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855/vf-modules/vf-module/788cde64-c288-4971-8e8c-77973c5009dc" - }, - { - "id": "3008335920", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08" - }, - { - "id": "3477385312", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" - } - ] - }, - { - "id": "3418898432", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855", - "properties": { - "vnf-id": "8e5e3ba1-3fe6-4d86-966e-f9f03dab4855", - "vnf-name": "zolson3amdns02test2", - "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "PREPROV", - "orchestration-status": "Created", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1507132024933", - "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "model-version-id": "76e908e0-5201-44d2-a3e2-9e6128d05820", - "model-customization-id": "c00e8fc8-af39-4da8-8c78-a7efc2fe5994", - "nf-type": "DNS", - "nf-function": "Mobile DNS", - "nf-role": "vMobileDNS", - "nf-naming-code": "null" - }, - "related-to": [ - { - "id": "3664617648", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855/vf-modules/vf-module/788cde64-c288-4971-8e8c-77973c5009dc" - }, - { - "id": "3008335920", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08" - }, - { - "id": "3477385312", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" - }, - { - "id": "3647635704", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/b30b17e9-10d0-4475-b558-7d18ae0aade0" - }, - { - "id": "3664621744", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/d3b293ba-85de-440e-904b-9dad160fbdce" - }, - { - "id": "3975352504", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/495a9a72-c9f6-41ed-93eb-065ebc2bfb1f" - }, - { - "id": "4059455552", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/b4b9f419-3ed4-4bd8-bb2e-32b0a98e80b7" - }, - { - "id": "4098130088", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/94c79f43-e76d-461e-b8df-8af2acb08e1e" - }, - { - "id": "4401291416", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/99cad3c6-1301-49c4-ad67-ae3c955de5f1" - }, - { - "id": "4458950808", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/047354dc-0244-4241-b24a-7d7b00413b82" - } - ] - }, - { - "id": "1024648346", - "node-type": "generic-vnf", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/a58bf551-a79c-42d1-83b4-ed9288036245", - "properties": { - "vnf-id": "a58bf551-a79c-42d1-83b4-ed9288036245", - "vnf-name": "Harrison Kris", - "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "PREPROV", - "orchestration-status": "Created", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "4679861552759", - "model-invariant-id": "00beb8f9-6d39-452f-816d-c709b9cbb87d", - "model-version-id": "0903e1c0-8e03-4936-b5c2-260653b96413", - "model-customization-id": "14e8057d-b22a-405c-84aa-90b82bfd6e46", - "nf-type": "DNS", - "nf-function": "Mobile DNS", - "nf-role": "vMobileDNS", - "nf-naming-code": "null" - }, - "related-to": [ - { - "id": "3664617648", - "node-type": "vf-module", - "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855/vf-modules/vf-module/788cde64-c288-4971-8e8c-77973c5009dc" - }, - { - "id": "3008335920", - "node-type": "service-instance", - "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08" - }, - { - "id": "3477385312", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" - }, - { - "id": "3647635704", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/b30b17e9-10d0-4475-b558-7d18ae0aade0" - }, - { - "id": "3664621744", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/d3b293ba-85de-440e-904b-9dad160fbdce" - }, - { - "id": "3975352504", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/495a9a72-c9f6-41ed-93eb-065ebc2bfb1f" - }, - { - "id": "4059455552", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/b4b9f419-3ed4-4bd8-bb2e-32b0a98e80b7" - }, - { - "id": "4098130088", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/94c79f43-e76d-461e-b8df-8af2acb08e1e" - }, - { - "id": "4401291416", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/99cad3c6-1301-49c4-ad67-ae3c955de5f1" - }, - { - "id": "4458950808", - "node-type": "vserver", - "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/047354dc-0244-4241-b24a-7d7b00413b82" - } - ] - } - ] - }
\ No newline at end of file diff --git a/vid-automation/src/test/resources/features.properties b/vid-automation/src/test/resources/features.properties index 796c8be8d..63b9fc61b 100644 --- a/vid-automation/src/test/resources/features.properties +++ b/vid-automation/src/test/resources/features.properties @@ -35,4 +35,4 @@ FLAG_1908_MACRO_NOT_TRANSPORT_NEW_VIEW_EDIT = true FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH = false FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG = true FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE = false - +FLAG_SHOW_ORCHESTRATION_TYPE = false |