Merge "Replace SO client"
authorOfir Sonsino <os0695@intl.att.com>
Thu, 30 Aug 2018 08:35:19 +0000 (08:35 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 30 Aug 2018 08:35:19 +0000 (08:35 +0000)
33 files changed:
deliveries/pom.xml
epsdk-app-onap/pom.xml
epsdk-app-onap/version.properties
pom.xml
version.properties
vid-app-common/pom.xml
vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java
vid-app-common/src/main/java/org/onap/vid/aai/util/SystemPropertyHelper.java
vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
vid-app-common/src/main/java/org/onap/vid/asdc/rest/RestfulAsdcClient.java [deleted file]
vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/client/SyncRestClientInterface.java
vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java
vid-app-common/src/main/resources/adiod.zip
vid-app-common/src/main/resources/csar317927061915233480.zip
vid-app-common/src/main/resources/csar3933948645405128424.zip
vid-app-common/src/main/resources/service-AmpPhSvc-csar.zip
vid-app-common/src/main/resources/service-VdbeSrv-csar.zip
vid-app-common/src/main/resources/service-vf-csar.zip
vid-app-common/src/main/resources/service-vf-with-annotations.zip
vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js
vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java
vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java [deleted file]
vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java
vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java
vid-app-common/src/test/resources/WEB-INF/conf/system.properties
vid-app-common/version.properties
vid-automation/pom.xml
vid-webpack-master/LICENSE
vid-webpack-master/README.md
vid-webpack-master/package.json

index ef35eec..3768b81 100755 (executable)
@@ -62,7 +62,7 @@
                                                                        <descriptor>assembly/assembly-for-plugin.xml</descriptor>\r
                                                                </assembly>\r
                                                                <tags>\r
-                                                                 <tag>2.0-STAGING-latest</tag>\r
+                                                                 <tag>3.0-STAGING-latest</tag>\r
                                                                </tags>\r
                                                                    \r
                                                        </build>\r
index 2ec04fe..050c3c5 100755 (executable)
@@ -8,7 +8,7 @@
                the Portal team. -->\r
        <groupId>org.onap.vid</groupId>\r
        <artifactId>epsdk-app-onap</artifactId>\r
-       <version>2.0.0-SNAPSHOT</version>\r
+       <version>3.0.0-SNAPSHOT</version>\r
        <packaging>war</packaging>\r
        <name>ECOMP SDK Webapp for OpenSource</name>\r
        <description>ECOMP SDK Web Application for public release</description>\r
index 6a0ca5f..02144f0 100644 (file)
@@ -2,7 +2,7 @@
 # Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )\r
 # because they are used in Jenkins, whose plug-in doesn't support\r
 \r
-major=2\r
+major=3\r
 minor=0\r
 patch=0\r
 \r
diff --git a/pom.xml b/pom.xml
index 74ff570..f16ca60 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -79,7 +79,7 @@
        <properties>\r
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\r
-               <build.version>2.0.0-SNAPSHOT</build.version>\r
+               <build.version>3.0.0-SNAPSHOT</build.version>\r
                <nexusproxy>https://nexus.onap.org</nexusproxy>\r
                <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>\r
                <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>\r
                        <version>4.5.3</version>\r
                </dependency>\r
        </dependencies>\r
-       <version>2.0.0-SNAPSHOT</version>\r
+       <version>3.0.0-SNAPSHOT</version>\r
 </project>\r
index 6a0ca5f..02144f0 100644 (file)
@@ -2,7 +2,7 @@
 # Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )\r
 # because they are used in Jenkins, whose plug-in doesn't support\r
 \r
-major=2\r
+major=3\r
 minor=0\r
 patch=0\r
 \r
index 9a6210b..57d3de1 100755 (executable)
@@ -9,7 +9,7 @@
                inherit from a parent maven module. -->\r
        <groupId>org.onap.vid</groupId>\r
        <artifactId>vid-app-common</artifactId>\r
-       <version>2.0.0-SNAPSHOT</version>\r
+       <version>3.0.0-SNAPSHOT</version>\r
        <packaging>war</packaging>\r
        <name>VID Common</name>\r
        <description>VID Common code for opensource version</description>\r
index 6b17c93..f5625ce 100644 (file)
@@ -309,7 +309,7 @@ public class AAIRestInterface {
         */
        public Response RestPost(String fromAppId, String path, String payload, boolean xml) {
                String methodName = "RestPost";
-               String url=systemPropertyHelper.getFullServicePath(path);
+               String url=systemPropertyHelper.getServiceBasePath(path);
                String transId = UUID.randomUUID().toString();
                logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING);
 
@@ -317,7 +317,7 @@ public class AAIRestInterface {
                try {
                        initRestClient();
                        Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
-                       response = authenticateRequest(client.target(systemPropertyHelper.getFullServicePath(path))
+                       response = authenticateRequest(client.target(systemPropertyHelper.getServiceBasePath(path))
                                        .request()
                     .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
                                        .header(TRANSACTION_ID_HEADER, transId)
index ebf39c4..4d43d3b 100644 (file)
@@ -38,6 +38,10 @@ public class SystemPropertyHelper {
         return getSystemProperty(AAIProperties.AAI_SERVER_URL);
     }
 
+    public Optional<String> getAAIServerBaseUrl(){
+        return getSystemProperty(AAIProperties.AAI_SERVER_URL_BASE);
+    }
+
     public Optional<String> getAAIVIDUsername(){
         return getSystemProperty(AAIProperties.AAI_VID_USERNAME);
     }
@@ -70,6 +74,10 @@ public class SystemPropertyHelper {
         return getAAIServerUrl().orElse("") + path;
     }
 
+    public String getServiceBasePath(String path) {
+        return getAAIServerBaseUrl().orElse("") + path;
+    }
+
     public String getEncodedCredentials() throws InvalidPropertyException, UnsupportedEncodingException {
         String vidUsername = getAAIVIDUsername().orElseThrow(InvalidPropertyException::new);
         String vidPassword = Password.deobfuscate(getAAIVIDPasswd().orElseThrow(InvalidPropertyException::new));
index 4e0254c..fdbf2c2 100644 (file)
@@ -29,7 +29,10 @@ import java.util.UUID;
  * The Interface AsdcClient.
  */
 public interface AsdcClient {
-
+       class URIS{
+               public static final String METADATA_URL_TEMPLATE = "%s%s/%s/metadata";
+               public static final String TOSCA_MODEL_URL_TEMPLATE = "%s%s/%s/toscaModel";
+       }
        /**
         * Gets the service.
         *
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/RestfulAsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/RestfulAsdcClient.java
deleted file mode 100644 (file)
index 5dd0f4c..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.asdc.rest;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.vid.asdc.AsdcCatalogException;
-import org.onap.vid.asdc.AsdcClient;
-import org.onap.vid.asdc.beans.Service;
-import org.onap.vid.model.ModelConstants;
-import org.onap.vid.properties.VidProperties;
-import org.onap.vid.utils.Logging;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.springframework.http.HttpMethod;
-
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ResponseProcessingException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.util.Collections;
-import java.util.UUID;
-
-import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
-/**
- * The Class RestfulAsdcClient.
- */
-@SuppressWarnings("Duplicates")
-public class RestfulAsdcClient implements AsdcClient {
-
-
-    /**
-     * The Class Builder.
-     */
-    public static class Builder {
-
-        /**
-         * The client.
-         */
-        private final Client client;
-
-        /**
-         * The uri.
-         */
-        private final URI uri;
-
-        /**
-         * The auth.
-         */
-        private String auth = null;
-
-        /**
-         * Instantiates a new builder.
-         *
-         * @param client the client
-         * @param uri    the uri
-         */
-        public Builder(Client client, URI uri) {
-            this.client = client;
-            this.client.register(JacksonJsonProvider.class);
-            this.uri = uri;
-        }
-
-        /**
-         * Auth.
-         *
-         * @param auth the auth
-         * @return the builder
-         */
-        public Builder auth(String auth) {
-            this.auth = auth;
-            return this;
-        }
-
-        /**
-         * Builds the.
-         *
-         * @return the restful asdc client
-         */
-        public RestfulAsdcClient build() {
-            return new RestfulAsdcClient(this);
-        }
-    }
-
-    /**
-     * The Constant LOG.
-     */
-    static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RestfulAsdcClient.class);
-
-    final private static EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("asdc");
-
-    /**
-     * The client.
-     */
-    private final Client client;
-
-    /**
-     * The uri.
-     */
-    private final URI uri;
-
-    /**
-     * The common headers.
-     */
-    private final MultivaluedHashMap<String, Object> commonHeaders;
-
-    /**
-     * The auth.
-     */
-    private final String auth;
-
-    /**
-     * Instantiates a new restful asdc client.
-     *
-     * @param builder the builder
-     */
-    RestfulAsdcClient(Builder builder) {
-        client = builder.client;
-        uri = builder.uri;
-        auth = builder.auth;
-
-        commonHeaders = new MultivaluedHashMap<String, Object>();
-        commonHeaders.put("X-ECOMP-InstanceID", Collections.singletonList((Object) (SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME))));
-        commonHeaders.put("Authorization", Collections.singletonList((Object) (auth)));
-    }
-
-    private Path createTmpFile(InputStream csarInputStream) throws AsdcCatalogException {
-        final Path csarFile;
-        try {
-            csarFile = Files.createTempFile("csar", ".zip");
-            Files.copy(csarInputStream, csarFile, StandardCopyOption.REPLACE_EXISTING);
-        } catch (IOException e) {
-            throw new AsdcCatalogException("Caught IOException while creating CSAR", e);
-        }
-        return csarFile;
-    }
-
-    /**
-     * Gets the client.
-     *
-     * @return the client
-     */
-    private Client getClient() {
-        return client;
-    }
-
-    /* (non-Javadoc)
-     * @see org.onap.vid.asdc.AsdcClient#getService(java.util.UUID)
-     */
-    public Service getService(UUID uuid) throws AsdcCatalogException {
-
-        String path = VidProperties.getPropertyWithDefault(
-                ModelConstants.ASDC_SVC_API_PATH,
-                ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
-
-        String url = uri+path + "/" + uuid.toString() + "/metadata";
-        Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
-        try {
-            Response response = getClient()
-                    .target(uri)
-                    .path(path + "/" + uuid.toString() + "/metadata")
-                    .request(MediaType.APPLICATION_JSON)
-                    .headers(commonHeaders)
-                    .header(REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId())
-                    .get();
-            Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, response);
-            return response.readEntity(Service.class);
-        } catch (ResponseProcessingException e) {
-            //Couldn't convert response to Java type
-            throw new AsdcCatalogException("SDC response could not be processed", e);
-        } catch (ProcessingException e) {
-            //IO problems during request
-            throw new AsdcCatalogException("Failed to get a response from SDC service", e);
-        } catch (WebApplicationException e) {
-            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
-            throw new AsdcCatalogException(e);
-        }
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.onap.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
-     */
-    public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
-        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH,
-                ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
-
-        String url = uri+path + "/" + serviceUuid + "/toscaModel";
-        Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
-        try {
-            final InputStream csarInputStream = getClient()
-                    .target(uri)
-                    .path(path + "/" + serviceUuid + "/toscaModel")
-                    .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
-                    .headers(commonHeaders)
-                    .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
-                    .header(REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId())
-                    .get(InputStream.class);
-            Path toscaFilePath = createTmpFile(csarInputStream);
-            outgoingRequestsLogger.debug("Received {} {} . Tosca file was saved at: {}", HttpMethod.GET.name(), url, toscaFilePath.toAbsolutePath());
-            return toscaFilePath;
-        } catch (ResponseProcessingException e) {
-            //Couldn't convert response to Java type
-            throw new AsdcCatalogException("SDC response could not be processed", e);
-        } catch (ProcessingException e) {
-            //IO problems during request
-            throw new AsdcCatalogException("Failed to get a response from SDC service. Cause: "+e.getMessage(), e);
-        } catch (WebApplicationException e) {
-            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
-            throw new AsdcCatalogException(e);
-        }
-    }
-
-}
-
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
new file mode 100644 (file)
index 0000000..b4096f9
--- /dev/null
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 Nokia 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.asdc.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.google.common.collect.ImmutableMap;
+import io.vavr.control.Try;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.AsdcClient;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.client.SyncRestClientInterface;
+import org.onap.vid.model.ModelConstants;
+import org.onap.vid.properties.VidProperties;
+import org.onap.vid.utils.Logging;
+import org.springframework.http.HttpMethod;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM;
+import static org.onap.portalsdk.core.util.SystemProperties.APP_DISPLAY_NAME;
+import static org.onap.vid.asdc.AsdcClient.URIS.METADATA_URL_TEMPLATE;
+import static org.onap.vid.asdc.AsdcClient.URIS.TOSCA_MODEL_URL_TEMPLATE;
+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.utils.Logging.REQUEST_ID_HEADER_KEY;
+import static org.onap.vid.utils.Logging.logRequest;
+
+public class SdcRestClient implements AsdcClient {
+
+    private String baseUrl;
+    private String path;
+    private String auth;
+    private static final EELFLogger LOGGER = Logging.getRequestsLogger("asdc");
+
+    private SyncRestClientInterface syncRestClient;
+
+
+    public SdcRestClient(String baseUrl, String auth, SyncRestClientInterface client) {
+        this.syncRestClient = client;
+        this.auth = auth;
+        this.baseUrl = baseUrl;
+        this.path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+    }
+
+
+    @Override
+    public Service getService(UUID uuid) throws AsdcCatalogException {
+        String finalUrl = String.format(METADATA_URL_TEMPLATE, baseUrl, path, uuid);
+        logRequest(LOGGER, HttpMethod.GET, finalUrl);
+
+        return Try
+                .of(() -> syncRestClient.get(finalUrl, prepareHeaders(auth, APPLICATION_JSON), Collections.emptyMap(), Service.class))
+                .getOrElseThrow(AsdcCatalogException::new)
+                .getBody();
+
+    }
+
+    @Override
+    public Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException {
+        String finalUrl = String.format(TOSCA_MODEL_URL_TEMPLATE, baseUrl, path, uuid);
+        logRequest(LOGGER, HttpMethod.GET, finalUrl);
+
+        InputStream inputStream = Try
+                .of(() -> syncRestClient.getStream(finalUrl, prepareHeaders(auth, APPLICATION_OCTET_STREAM), Collections.emptyMap()))
+                .getOrElseThrow(AsdcCatalogException::new)
+                .getBody();
+
+        return createTmpFile(inputStream);
+    }
+
+
+    private Map<String, String> prepareHeaders(String auth, String contentType) {
+        return ImmutableMap.of(
+                X_ECOMP_INSTANCE_ID, SystemProperties.getProperty(APP_DISPLAY_NAME),
+                AUTHORIZATION, auth,
+                REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId(),
+                CONTENT_TYPE, contentType
+        );
+    }
+
+    private Path createTmpFile(InputStream csarInputStream) throws AsdcCatalogException {
+        return Try
+                .of(() -> tryToCreateTmpFile(csarInputStream))
+                .getOrElseThrow(throwable -> new AsdcCatalogException("Caught IOException while creating CSAR", throwable));
+    }
+
+    private Path tryToCreateTmpFile(InputStream csarInputStream) throws IOException {
+        Path csarFile = Files.createTempFile("csar", ".zip");
+        Files.copy(csarInputStream, csarFile, StandardCopyOption.REPLACE_EXISTING);
+
+        LOGGER.debug("Tosca file was saved at: {} ", csarFile.toAbsolutePath());
+
+        return csarFile;
+    }
+}
index 80663d6..142adde 100644 (file)
@@ -2,16 +2,22 @@ package org.onap.vid.client;
 
 import io.joshworks.restclient.http.HttpResponse;
 import io.joshworks.restclient.http.JsonNode;
+
 import java.io.InputStream;
 import java.util.Map;
 
 public interface SyncRestClientInterface {
+    class HEADERS {
+        public static final String CONTENT_TYPE = "Content-Type";
+        public static final String AUTHORIZATION = "Authorization";
+        public static final String X_ECOMP_INSTANCE_ID = "X-ECOMP-InstanceID";
+    }
 
     HttpResponse<JsonNode> post(String url, Map<String, String> headers, Object body);
 
     <T> HttpResponse<T> post(String url, Map<String, String> headers, Object body, Class<T> aClass);
 
-    HttpResponse<JsonNode> get(String url, Map<String, String> headers,  Map<String, String> routeParams);
+    HttpResponse<JsonNode> get(String url, Map<String, String> headers, Map<String, String> routeParams);
 
     <T> HttpResponse<T> get(String url, Map<String, String> headers, Map<String, String> routeParams, Class<T> aClass);
 
@@ -19,9 +25,9 @@ public interface SyncRestClientInterface {
 
     HttpResponse<JsonNode> put(String url, Map<String, String> headers, Object body);
 
-    <T> HttpResponse<T> put(String url, Map<String, String> headers, Object body,  Class<T> aClass);
+    <T> HttpResponse<T> put(String url, Map<String, String> headers, Object body, Class<T> aClass);
 
-    <T> HttpResponse<T> delete(String url, Map<String, String> headers,  Class<T> aClass);
+    <T> HttpResponse<T> delete(String url, Map<String, String> headers, Class<T> aClass);
 
     HttpResponse<JsonNode> delete(String url, Map<String, String> headers);
 
index cf32e92..0f4b536 100644 (file)
 package org.onap.vid.controllers;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.vid.aai.*;
+import org.onap.vid.aai.AaiClient;
+import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.AaiResponseTranslator;
+import org.onap.vid.aai.PombaClientImpl;
+import org.onap.vid.aai.PombaClientInterface;
+import org.onap.vid.aai.PombaRestInterface;
 import org.onap.vid.aai.model.PortDetailsTranslator;
-import org.onap.vid.aai.util.*;
+import org.onap.vid.aai.util.AAIRestInterface;
+import org.onap.vid.aai.util.HttpsAuthClient;
+import org.onap.vid.aai.util.SSLContextProvider;
+import org.onap.vid.aai.util.ServletRequestHelper;
+import org.onap.vid.aai.util.SystemPropertyHelper;
 import org.onap.vid.asdc.AsdcClient;
 import org.onap.vid.asdc.parser.ToscaParserImpl2;
-import org.onap.vid.asdc.rest.RestfulAsdcClient;
-import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.asdc.rest.SdcRestClient;
+import org.onap.vid.client.SyncRestClient;
+import org.onap.vid.client.SyncRestClientInterface;
 import org.onap.vid.properties.AsdcClientConfiguration;
+import org.onap.vid.services.AaiService;
+import org.onap.vid.services.AaiServiceImpl;
+import org.onap.vid.services.PombaService;
+import org.onap.vid.services.PombaServiceImpl;
+import org.onap.vid.services.VidService;
+import org.onap.vid.services.VidServiceImpl;
 import org.onap.vid.scheduler.SchedulerRestInterface;
 import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
 import org.onap.vid.services.*;
@@ -38,15 +54,8 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.togglz.core.manager.FeatureManager;
 
-import javax.net.ssl.SSLContext;
 import javax.servlet.ServletContext;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
 import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 
 @Configuration
 public class WebConfig {
@@ -119,35 +128,18 @@ public class WebConfig {
     }
 
     @Bean
-    public AsdcClient asdcClient(AsdcClientConfiguration asdcClientConfig) {
-
-        final String protocol = asdcClientConfig.getAsdcClientProtocol();
-        final String host = asdcClientConfig.getAsdcClientHost();
-        final int port = asdcClientConfig.getAsdcClientPort();
-        final String auth = asdcClientConfig.getAsdcClientAuth();
-        Client cl = null;
-        if (protocol.equalsIgnoreCase("https")) {
-            try {
-                SSLContext ctx = SSLContext.getInstance("TLSv1.2");
-                ctx.init(null, null, null);
-                cl = ClientBuilder.newBuilder().sslContext(ctx).build();
-            } catch (NoSuchAlgorithmException n) {
-                throw new GenericUncheckedException("SDC Client could not be instantiated due to unsupported protocol TLSv1.2", n);
-            } catch (KeyManagementException k) {
-                throw new GenericUncheckedException("SDC Client could not be instantiated due to a key management exception", k);
-            }
-        } else {
-            cl = ClientBuilder.newBuilder().build();
-        }
-
-        try {
-            final URI uri = new URI(protocol + "://" + host + ":" + port + "/");
-            return new RestfulAsdcClient.Builder(cl, uri)
-                    .auth(auth)
-                    .build();
-        } catch (URISyntaxException e) {
-            throw new GenericUncheckedException("SDC Client could not be instantiated due to a syntax error in the URI", e);
-        }
+    public AsdcClient sdcClient(AsdcClientConfiguration asdcClientConfiguration, SyncRestClientInterface syncRestClient) {
+        String auth = asdcClientConfiguration.getAsdcClientAuth();
+        String host = asdcClientConfiguration.getAsdcClientHost();
+        String protocol = asdcClientConfiguration.getAsdcClientProtocol();
+        int port = asdcClientConfiguration.getAsdcClientPort();
+
+        return new SdcRestClient(protocol + "://" + host + ":" + port + "/", auth, syncRestClient);
+    }
+
+    @Bean
+    public SyncRestClientInterface syncRestClient() {
+        return new SyncRestClient();
     }
 
     @Bean
index 415fa48..6c928a3 100644 (file)
Binary files a/vid-app-common/src/main/resources/adiod.zip and b/vid-app-common/src/main/resources/adiod.zip differ
index 36ac9f9..ce58b17 100644 (file)
Binary files a/vid-app-common/src/main/resources/csar317927061915233480.zip and b/vid-app-common/src/main/resources/csar317927061915233480.zip differ
index b92d533..ee9b4fb 100644 (file)
Binary files a/vid-app-common/src/main/resources/csar3933948645405128424.zip and b/vid-app-common/src/main/resources/csar3933948645405128424.zip differ
index 6d5002c..1591a48 100644 (file)
Binary files a/vid-app-common/src/main/resources/service-AmpPhSvc-csar.zip and b/vid-app-common/src/main/resources/service-AmpPhSvc-csar.zip differ
index 3defd1e..0b8db27 100644 (file)
Binary files a/vid-app-common/src/main/resources/service-VdbeSrv-csar.zip and b/vid-app-common/src/main/resources/service-VdbeSrv-csar.zip differ
index f66d084..c3a9fbb 100644 (file)
Binary files a/vid-app-common/src/main/resources/service-vf-csar.zip and b/vid-app-common/src/main/resources/service-vf-csar.zip differ
index a742d60..a6fcce7 100644 (file)
Binary files a/vid-app-common/src/main/resources/service-vf-with-annotations.zip and b/vid-app-common/src/main/resources/service-vf-with-annotations.zip differ
index c85e865..89660fb 100755 (executable)
                                                "category":serviceModel.service.category\r
                                        });\r
                                        DataService.setALaCarte (true);\r
+          DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));\r
                                        $scope.createType = COMPONENT.A_LA_CARTE;\r
                                        var broadcastType = COMPONENT.CREATE_COMPONENT;\r
                     if (AsdcService.isMacro(serviceModel)) {\r
index 288b891..cd2b8ff 100644 (file)
@@ -302,6 +302,7 @@ public class SingleAAIRestInterfaceTest {
         when(systemPropertyHelper.getAAIVIDUsername()).thenReturn(Optional.of("user"));
         when(systemPropertyHelper.getEncodedCredentials()).thenReturn("someCredentials");
         when(systemPropertyHelper.getFullServicePath(Mockito.anyString())).thenReturn("http://localhost/path");
+        when(systemPropertyHelper.getServiceBasePath(Mockito.anyString())).thenReturn("http://localhost/path");
     }
 
 }
\ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java
deleted file mode 100644 (file)
index 75b84b2..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.onap.vid.asdc.rest;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.onap.vid.testUtils.TestUtils;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.client.Client;
-import java.net.URI;
-import java.util.UUID;
-import java.util.function.Consumer;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-import static org.testng.AssertJUnit.fail;
-
-public class RestfulAsdcClientTest {
-
-    @DataProvider
-    public static Object[][] javaxExceptions() {
-
-        return new Object[][] {
-                {NotFoundException.class, (Consumer<Client>) javaxClientMock ->
-                        when(javaxClientMock.target(any(URI.class))).thenThrow(
-                                new NotFoundException("HTTP 404 Not Found"))},
-                {ProcessingException.class, (Consumer<Client>) javaxClientMock ->
-                        when(javaxClientMock.target(any(URI.class))).thenThrow(
-                                new ProcessingException("java.net.ConnectException: Connection refused: connect"))},
-        };
-    }
-
-
-    @Test(dataProvider = "javaxExceptions")
-    public void whenJavaxClientThrowException_thenExceptionRethrown(Class<? extends Throwable> expectedType, Consumer<Client> setupMocks) throws Exception {
-        /*
-        Call chain is like:
-            this test -> RestfulAsdcClient ->  javax's Client
-
-        In this test, *RestfulAsdcClient* is under test (actual implementation is used), while javax's Client is
-        mocked to return pseudo-responses or - better - throw exceptions.
-         */
-
-        // prepare mocks
-        TestUtils.JavaxRsClientMocks mocks = new TestUtils.JavaxRsClientMocks();
-        Client javaxClientMock = mocks.getFakeClient();
-
-        // prepare real RestfulAsdcClient (Under test)
-        RestfulAsdcClient restfulAsdcClient = new RestfulAsdcClient.Builder(javaxClientMock, new URI(""))
-                .auth("")
-                .build();
-
-        /// TEST:
-        setupMocks.accept(javaxClientMock);
-
-        try {
-            restfulAsdcClient.getServiceToscaModel(UUID.randomUUID());
-        } catch (Exception e) {
-            assertThat("root cause incorrect for " + ExceptionUtils.getStackTrace(e), ExceptionUtils.getRootCause(e), instanceOf(expectedType));
-            return; //OK
-        }
-
-        fail("exception shall rethrown by getServiceToscaModel once javax client throw exception ");
-    }
-
-}
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
new file mode 100644 (file)
index 0000000..2ef3374
--- /dev/null
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 Nokia 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.asdc.rest;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.xebialabs.restito.semantics.Call;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContextBuilder;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.client.SyncRestClient;
+import org.onap.vid.testUtils.StubServerUtil;
+
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.GeneralSecurityException;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.UUID;
+
+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.is;
+import static org.hamcrest.Matchers.matchesPattern;
+import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
+import static org.junit.Assert.assertTrue;
+import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID;
+import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+
+
+public class SdcRestClientITTest {
+    private static final String UUID_REGEX = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
+    private static final String[] SUPPORTED_SSL_VERSIONS = {"TLSv1", "TLSv1.2"};
+    private static StubServerUtil stubServer;
+    private static SdcRestClient sdcRestClient;
+
+    @BeforeClass
+    public static void setUpClass() throws GeneralSecurityException {
+        stubServer = new StubServerUtil();
+        stubServer.runSecuredServer();
+        SyncRestClient syncRestClient = new SyncRestClient(createNaiveHttpClient());
+        String serverUrl = stubServer.constructTargetUrl("https", "");
+        sdcRestClient = new SdcRestClient(serverUrl, "", syncRestClient);
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        stubServer.stopServer();
+    }
+
+    @Test
+    public void shouldDownloadToscaArtifactUsingSecuredEndpoint() throws AsdcCatalogException, IOException {
+        UUID uuid = UUID.randomUUID();
+        String expectedEndpoint = String.format("/sdc/v1/catalog/services/%s/toscaModel", uuid);
+
+        stubServer.prepareGetCall(
+                expectedEndpoint, stringContent("sampleFileContent"), "sampleFileContent", ok(), "application/octet-stream");
+
+
+        Path serviceToscaModel = sdcRestClient.getServiceToscaModel(uuid);
+        serviceToscaModel.toFile().deleteOnExit();
+
+
+        assertThat(Files.readAllLines(serviceToscaModel), contains("sampleFileContent"));
+        assertThatRequestHasRequiredHeaders(expectedEndpoint);
+    }
+
+    @Test
+    public void shouldGetServiceDetailsUsingSecuredEndpoint() throws AsdcCatalogException, JsonProcessingException {
+        UUID uuid = UUID.randomUUID();
+        String expectedEndpoint = String.format("/sdc/v1/catalog/services/%s/metadata", uuid);
+        Service expectedService = getExpectedService(uuid.toString());
+
+
+        stubServer.prepareGetCall(expectedEndpoint, expectedService, ok());
+
+
+        Service actualService = sdcRestClient.getService(uuid);
+
+
+        assertThat(actualService, is(expectedService));
+        assertThatRequestHasRequiredHeaders(expectedEndpoint);
+    }
+
+    private void assertThatRequestHasRequiredHeaders(String expectedEndpoint) {
+        Optional<Call> first = stubServer
+                .getServerCalls()
+                .stream()
+                .filter(x -> x.getUri().contains(expectedEndpoint))
+                .findFirst();
+
+        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));
+    }
+
+    private Service getExpectedService(String stringId) {
+        return new Service(stringId, stringId,
+                "sampleCategory", "sampleVersion",
+                "sampleName", "sampleDistStatus",
+                "sampleToscaUrl", Service.LifecycleState.CERTIFIED, Collections.emptyList(), Collections.emptyList());
+    }
+
+
+    private static CloseableHttpClient createNaiveHttpClient() throws GeneralSecurityException {
+        final SSLContext context = new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
+                .build();
+
+        final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(context, SUPPORTED_SSL_VERSIONS,
+                null, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+        Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
+                .register("https", socketFactory)
+                .build();
+
+        return HttpClientBuilder.create()
+                .setDefaultRequestConfig(custom().setConnectionRequestTimeout(10000).build())
+                .setConnectionManager(new PoolingHttpClientConnectionManager(registry))
+                .setSSLSocketFactory(socketFactory).build();
+    }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java
new file mode 100644 (file)
index 0000000..c1d6ab7
--- /dev/null
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 Nokia 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.asdc.rest;
+
+import io.joshworks.restclient.http.HttpResponse;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.client.SyncRestClient;
+
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.util.UUID;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyMapOf;
+import static org.mockito.Matchers.matches;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SdcRestClientTest {
+
+    private static final String SAMPLE_SERVICE_NAME = "sampleService";
+    private static final String SAMPLE_BASE_URL = "baseUrl";
+    private static final String SAMPLE_AUTH = "sampleAuth";
+    private static final String METADATA_URL_REGEX = ".*sdc/v1/catalog/services/%s/metadata";
+    private static final String MODEL_URL_REGEX = ".*sdc/v1/catalog/services/%s/toscaModel";
+
+
+    @Mock
+    private SyncRestClient mockedSyncRestClient;
+
+    @Mock
+    private HttpResponse<Object> httpResponse;
+
+    @Mock
+    private HttpResponse<InputStream> httpStreamResponse;
+
+    @Mock
+    private InputStream inputStream;
+
+    private UUID randomId;
+
+    private Service sampleService;
+
+    private SdcRestClient restClient;
+
+
+    @Before
+    public void setUp() {
+        randomId = UUID.randomUUID();
+        sampleService = createTestService();
+        restClient = new SdcRestClient(SAMPLE_BASE_URL, SAMPLE_AUTH, mockedSyncRestClient);
+    }
+
+
+    @Test
+    public void shouldReturnServiceForGivenUUID() throws AsdcCatalogException {
+        String url = String.format(METADATA_URL_REGEX, randomId);
+        when(mockedSyncRestClient.get(matches(url), anyMapOf(String.class, String.class), anyMapOf(String.class, String.class), any())).thenReturn(httpResponse);
+        when(httpResponse.getBody()).thenReturn(sampleService);
+
+        Service service = restClient.getService(randomId);
+
+
+        assertThat(service, is(sampleService));
+    }
+
+    @Test(expected = AsdcCatalogException.class)
+    public void shouldRaiseAsdcExceptionWhenClientFails() throws AsdcCatalogException {
+        String url = String.format(METADATA_URL_REGEX, randomId);
+        when(mockedSyncRestClient.get(matches(url), anyMapOf(String.class, String.class), anyMapOf(String.class, String.class), any())).thenThrow(new RuntimeException());
+
+        restClient.getService(randomId);
+    }
+
+
+    @Test
+    public void shouldProperlyDownloadAndCopyToscaArtifact() throws AsdcCatalogException {
+        String url = String.format(MODEL_URL_REGEX, randomId);
+        when(mockedSyncRestClient.getStream(matches(url), any(), any())).thenReturn(httpStreamResponse);
+        when(httpStreamResponse.getBody()).thenReturn(inputStream);
+
+
+        Path serviceToscaModel = restClient.getServiceToscaModel(randomId);
+
+
+        assertThat(serviceToscaModel, notNullValue());
+        assertThat(serviceToscaModel.toFile().isFile(), is(true));
+
+        serviceToscaModel.toFile().deleteOnExit();
+    }
+
+    @Test(expected = AsdcCatalogException.class)
+    public void shouldRaiseAsdcExceptionWhenDownloadFails() throws AsdcCatalogException {
+        String url = String.format(MODEL_URL_REGEX, randomId);
+        when(mockedSyncRestClient.getStream(matches(url), anyMapOf(String.class, String.class), anyMapOf(String.class, String.class))).thenThrow(new RuntimeException());
+
+
+        restClient.getServiceToscaModel(randomId);
+    }
+
+
+    private Service createTestService() {
+        Service service = new Service();
+        service.setInvariantUUID(randomId.toString());
+        service.setUuid(randomId.toString());
+        service.setName(SAMPLE_SERVICE_NAME);
+        return service;
+    }
+
+}
\ No newline at end of file
index da2600e..909975f 100644 (file)
@@ -2,9 +2,13 @@ package org.onap.vid.mso.rest;
 
 import com.google.common.collect.ImmutableList;
 import org.apache.commons.lang3.reflect.FieldUtils;
-import org.mockito.*;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
 import org.onap.vid.aai.util.AAIRestInterface;
-import org.onap.vid.asdc.rest.RestfulAsdcClient;
 import org.onap.vid.changeManagement.RequestDetailsWrapper;
 import org.onap.vid.controller.filter.PromiseEcompRequestIdFilter;
 import org.onap.vid.mso.RestMsoImplementation;
@@ -27,10 +31,13 @@ import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static java.util.UUID.randomUUID;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-import static org.mockito.Mockito.mock;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.equalToIgnoringCase;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasToString;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.matchesPattern;
 
 
 public class OutgoingRequestIdTest {
@@ -42,7 +49,6 @@ public class OutgoingRequestIdTest {
     @InjectMocks
     private AAIRestInterface aaiRestInterface;
 
-    private RestfulAsdcClient restfulAsdcClient = new RestfulAsdcClient.Builder(mock(Client.class), null).build();
 
     @Captor
     private ArgumentCaptor<MultivaluedMap<String, Object>> multivaluedMapArgumentCaptor;
@@ -57,23 +63,6 @@ public class OutgoingRequestIdTest {
         RequestContextHolder.setRequestAttributes(new ServletRequestAttributes((HttpServletRequest) PromiseEcompRequestIdFilter.wrapIfNeeded(new MockHttpServletRequest())));
     }
 
-    @DataProvider
-    public Object[][] sdcMethods() {
-        return Stream.<ThrowingConsumer<RestfulAsdcClient>>of(
-                client -> client.getService(randomUUID()),
-                client -> client.getServiceToscaModel(randomUUID())
-        ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{});
-    }
-
-    @Test(dataProvider = "sdcMethods")
-    public void sdc(Consumer<RestfulAsdcClient> f) throws Exception {
-        final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restfulAsdcClient);
-
-        f.accept(restfulAsdcClient);
-
-        verifyRequestIdHeaderWasAdded(mocks.getFakeBuilder());
-    }
-
     @DataProvider
     public Object[][] msoMethods() {
         return Stream.<ThrowingConsumer<RestMsoImplementation>>of(
index e84655f..f7ffd9a 100644 (file)
@@ -23,9 +23,12 @@ package org.onap.vid.testUtils;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.xebialabs.restito.semantics.Action;
+import com.xebialabs.restito.semantics.Call;
 import com.xebialabs.restito.semantics.Condition;
 import com.xebialabs.restito.server.StubServer;
 
+import java.util.List;
+
 import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
 import static com.xebialabs.restito.semantics.Action.contentType;
 import static com.xebialabs.restito.semantics.Action.stringContent;
@@ -48,6 +51,10 @@ public class StubServerUtil {
         stubServer.run();
     }
 
+    public void runSecuredServer(){
+        stubServer.secured().run();
+    }
+
     public void stopServer() {
         stubServer.stop();
     }
@@ -57,10 +64,15 @@ public class StubServerUtil {
         return String.format("%s://localhost:%s/%s", protocol, stubServer.getPort(), relativePath);
     }
 
-    public void prepareGetCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
+    public void prepareGetCall(String path, Action actionToReturn,Object returnObj, Action expectedAction, String contentType) throws JsonProcessingException {
         whenHttp(stubServer)
                 .match(Condition.get(path))
-                .then(expectedAction, jsonContent(returnObj), contentType(APPLICATION_JSON));
+                .then(expectedAction, actionToReturn, contentType(contentType));
+    }
+
+
+    public void prepareGetCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
+        prepareGetCall(path, jsonContent(returnObj),returnObj, expectedAction, APPLICATION_JSON);
     }
 
     public void prepareDeleteCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
@@ -83,6 +95,10 @@ public class StubServerUtil {
                 .then(expectedStatus, jsonContent(returnObj), contentType(APPLICATION_JSON));
     }
 
+    public List<Call> getServerCalls() {
+        return stubServer.getCalls();
+    }
+
     private Action jsonContent(Object returnObj) throws JsonProcessingException {
         return stringContent(objectMapper.writeValueAsString(returnObj));
     }
index a67f578..8eb70a8 100644 (file)
@@ -178,8 +178,8 @@ mso.dme2.server.url=http://mso-api-handler-anap-v1.mso.ecomp.att.com/services/ec
 #mso.dme2.server.url=https://ActiveAndAvailableInventory-CloudNetwork-v1.aai.att.com/aai?version=1&envContext=DEV&routeOffer=devINT1
 mso.dme2.enabled=false
 asdc.model.namespace=org.openecomp.
-sdc.svc.api.path=asdc/v1/catalog/services
-sdc.resource.api.path=asdc/v1/catalog/resource
+sdc.svc.api.path=sdc/v1/catalog/services
+sdc.resource.api.path=sdc/v1/catalog/resource
 
 # Application base URL has the host and app context only; a proper prefix of the on-boarded URL.
 # Only required for applications using WebJunction or FE/BE separation.  For example:
index 6a0ca5f..02144f0 100755 (executable)
@@ -2,7 +2,7 @@
 # Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )\r
 # because they are used in Jenkins, whose plug-in doesn't support\r
 \r
-major=2\r
+major=3\r
 minor=0\r
 patch=0\r
 \r
index bf34a4f..75d48a4 100644 (file)
@@ -1,7 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>org.onap.vid</groupId>
@@ -12,7 +10,7 @@
         <jersey.version>2.23.1</jersey.version>
         <jackson.version>2.6.3</jackson.version>
         <aspectj.version>1.8.10</aspectj.version>
-         
+
     </properties>
 
 
@@ -20,7 +18,7 @@
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
-            <version>23.0</version>
+
         </dependency>
         <dependency>
             <groupId>org.openecomp.sdc</groupId>
             </plugin>
         </plugins>
     </build>
-</project>
\ No newline at end of file
+</project>
index ad6b740..90ec86c 100644 (file)
@@ -1,3 +1,5 @@
+The vid-webpack-master project is provided under the Apache License, version 2.0 (Apache-2.0). It includes code from the angular-webpack template files, which were originally provided under the following license: 
+
 The MIT License (MIT)
 
 Copyright (c) 2016 Preboot team
index 5c37773..25a7588 100644 (file)
@@ -145,5 +145,5 @@ We have good experience using these editors:
 * [Sublime Text](http://www.sublimetext.com/3) with [Typescript-Sublime-Plugin](https://github.com/Microsoft/Typescript-Sublime-plugin#installation)
 
 # License
+The vid-webpack-master project is provided under the Apache License, version 2.0 (Apache-2.0). It includes code from the angular-webpack template files, which were originally provided under the MIT license.
 
-[MIT](/LICENSE)
index 8cb4b92..168ad95 100644 (file)
@@ -1,7 +1,7 @@
 {
   "name": "vid-cli",
   "version": "0.0.0",
-  "license": "MIT",
+  "license": "Apache-2.0",
   "scripts": {
     "ng": "ng",
     "start": "ng serve --port 4201",