summaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-design-services/provider/src
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-18 12:23:23 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-18 20:37:13 +0000
commitfcf5ab8738a4681301130a0b66ee64a7c0af264d (patch)
tree0b4f82e311fb1214dac3eb747fabfcee5a65f8a2 /appc-inbound/appc-design-services/provider/src
parent71c17fc5f279a598526a2798dc15e040a753fef6 (diff)
Test coverage in design-services-provider
Add test cases to ArtifactHandlerClient Issue-ID: APPC-1436 Change-Id: I0893526b6f3a532ec422b998bb9cc266850a52a7 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-inbound/appc-design-services/provider/src')
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java17
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java6
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java167
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/services/util/ArtifactHandlerClientTest.java46
4 files changed, 144 insertions, 92 deletions
diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java
index 36465d98f..af9dfc9ec 100644
--- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,8 +29,6 @@ import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -118,15 +118,15 @@ public class DesignDBService {
private String getAppcTimestampUTC( String requestID) throws Exception
{
- log.info("Starting getAppcTimestampUTC: requestID:"+ requestID );
+ log.info("Starting getAppcTimestampUTC: requestID:" + requestID );
java.util.TimeZone gmtTZ= java.util.TimeZone.getTimeZone("GMT");
java.text.SimpleDateFormat formatter =
new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
formatter.setTimeZone( gmtTZ );
java.util.Date dateVal= new java.util.Date();
- log.info("getAppcTimestampUTC: current local Date:["+ dateVal+"]");
+ log.info("getAppcTimestampUTC: current local Date:[" + dateVal+ "]");
String timeStr= formatter.format( dateVal );
- log.info("getAppcTimestampUTC: returning:["+timeStr+"]");
+ log.info("getAppcTimestampUTC: returning:[" + timeStr + "]");
return timeStr;
}
@@ -623,13 +623,10 @@ public class DesignDBService {
}
}
-
public static class ArtifactHandlerFactory {
-
+
public ArtifactHandlerClient ahi() throws Exception{
return new ArtifactHandlerClient();
}
- }
+ }
}
-
-
diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java
index 521151a47..a75f8d21f 100644
--- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,11 +52,11 @@ import javax.ws.rs.core.MediaType;
public class ArtifactHandlerClient {
private static final EELFLogger log = EELFManager.getInstance().getLogger(ArtifactHandlerClient.class);
- private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
+ static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
private Properties props = new Properties();
public ArtifactHandlerClient() throws IOException {
- String propDir = System.getenv(SDNC_CONFIG_DIR_VAR);
+ String propDir = DesignServiceConstants.getEnvironmentVariable(SDNC_CONFIG_DIR_VAR);
if (propDir == null) {
throw new IOException(" Cannot find Property file -" + SDNC_CONFIG_DIR_VAR);
}
diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java
index f7208bf03..7bc8f40eb 100644
--- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,87 +26,92 @@
package org.onap.appc.design.services.util;
public class DesignServiceConstants {
-
- public static final String STRING_ENCODING = "utf-8";
- public static final String Y = "Y";
- public static final String N = "N";
- public static final String DATA_TYPE_TEXT = "TEXT";
- public static final String DATA_TYPE_JSON = "JSON";
- public static final String DATA_TYPE_XML = "XML";
- public static final String DATA_TYPE_YAML = "YAML";
- public static final String DATA_TYPE_VELOCITY = "VELOCITY";
- public static final String DATA_TYPE_SQL = "SQL";
-
- public static final String GETDESIGNS = "getDesigns";
- public static final String GETAPPCTIMESTAMPUTC = "getAppcTimestampUTC";
- public static final String UPLOADARTIFACTS = "uploadArtifacts";
- public static final String VALIDATETEMPLATE = "validateTemplate";
- public static final String GETSTATUS = "getStatus";
- public static final String SETSTATUS = "setStatus";
- public static final String GETGUIREFERENCE = "getGUIReference";
- public static final String GETARTIFACTREFERENCE = "getArtifactReference";
- public static final String GETAAIDATA = "getAAIData";
- public static final String GETINSTARDATA = "getInstarData";
- public static final String PUBLISHARTIFACTS = "publishdArtifacts";
- public static final String ADDINCART = "addInCart";
-
- public static final String SUCCESS = "success";
- public static final String DESINGTIME = "DesignTime";
- public static final String RUNTIME = "RunTime";
- public static final String APPC_FLOW_CONTROLLER = "/appc-flow-controller.properties";
- public static final String VNF_TYPE = "vnf-type";
- public static final String ACTION = "action";
- public static final String VNFC_TYPE = "vnfc-type";
- public static final String VM_INSTANCE = "vm-instance";
- public static final String VM = "vm";
- public static final String VNFC = "vnfc";
-
- public static final String DOCUMENT_PARAMETERS = "document-parameters";
- public static final String SERVICE_UUID = "service-uuid";
- public static final String DISTRIBUTION_ID = "distribution-id";
- public static final String SERVICE_NAME = "service-name";
- public static final String SERVICE_DESCRIPTION ="service-description";
- public static final String SERVICE_ARTIFACTS = "service-artifacts";
- public static final String RESOURCE_UUID ="resource-uuid";
- public static final String RESOURCE_INSTANCE_NAME = "resource-instance-name";
- public static final String REOURCE_NAME = "resource-name";
- public static final String RESOURCE_VERSOIN ="resource-version";
- public static final String RESOURCE_TYPE= "resource-type";
- public static final String ARTIFACT_UUID ="artifact-uuid";
- public static final String ARTIFACT_NAME = "artifact-name";
+ public static final String STRING_ENCODING = "utf-8";
+ public static final String Y = "Y";
+ public static final String N = "N";
+ public static final String DATA_TYPE_TEXT = "TEXT";
+ public static final String DATA_TYPE_JSON = "JSON";
+ public static final String DATA_TYPE_XML = "XML";
+ public static final String DATA_TYPE_YAML = "YAML";
+ public static final String DATA_TYPE_VELOCITY = "VELOCITY";
+ public static final String DATA_TYPE_SQL = "SQL";
+
+ public static final String GETDESIGNS = "getDesigns";
+ public static final String GETAPPCTIMESTAMPUTC = "getAppcTimestampUTC";
+ public static final String UPLOADARTIFACTS = "uploadArtifacts";
+ public static final String VALIDATETEMPLATE = "validateTemplate";
+ public static final String GETSTATUS = "getStatus";
+ public static final String SETSTATUS = "setStatus";
+ public static final String GETGUIREFERENCE = "getGUIReference";
+ public static final String GETARTIFACTREFERENCE = "getArtifactReference";
+ public static final String GETAAIDATA = "getAAIData";
+ public static final String GETINSTARDATA = "getInstarData";
+ public static final String PUBLISHARTIFACTS = "publishdArtifacts";
+ public static final String ADDINCART = "addInCart";
+
+ public static final String SUCCESS = "success";
+ public static final String DESINGTIME = "DesignTime";
+ public static final String RUNTIME = "RunTime";
+ public static final String APPC_FLOW_CONTROLLER = "/appc-flow-controller.properties";
+ public static final String VNF_TYPE = "vnf-type";
+ public static final String ACTION = "action";
+ public static final String VNFC_TYPE = "vnfc-type";
+ public static final String VM_INSTANCE = "vm-instance";
+ public static final String VM = "vm";
+ public static final String VNFC = "vnfc";
+
+ public static final String DOCUMENT_PARAMETERS = "document-parameters";
+ public static final String SERVICE_UUID = "service-uuid";
+ public static final String DISTRIBUTION_ID = "distribution-id";
- public static final String ARTIFACT_VERSOIN = "artifact-version";
- public static final String ARTIFACT_DESRIPTION = "artifact-description";
- public static final String ARTIFACT_CONTENTS = "artifact-contents";
- public static final String REQUEST_INFORMATION = "request-information";
- public static final String INTERNAL_VERSION = "internal-versoin";
-
+ public static final String SERVICE_NAME = "service-name";
+ public static final String SERVICE_DESCRIPTION ="service-description";
+ public static final String SERVICE_ARTIFACTS = "service-artifacts";
+ public static final String RESOURCE_UUID ="resource-uuid";
+ public static final String RESOURCE_INSTANCE_NAME = "resource-instance-name";
+ public static final String REOURCE_NAME = "resource-name";
+ public static final String RESOURCE_VERSOIN ="resource-version";
+ public static final String RESOURCE_TYPE= "resource-type";
+ public static final String ARTIFACT_UUID ="artifact-uuid";
+ public static final String ARTIFACT_NAME = "artifact-name";
+
+ public static final String ARTIFACT_VERSOIN = "artifact-version";
+ public static final String ARTIFACT_DESRIPTION = "artifact-description";
+ public static final String ARTIFACT_CONTENTS = "artifact-contents";
+ public static final String REQUEST_INFORMATION = "request-information";
+ public static final String INTERNAL_VERSION = "internal-versoin";
+
+ public static final String DB_DT_ARTIFACT_TRACKING = "DT_ARTIFACT_TRACKING";
+ public static final String DB_SDC_REFERENCE = "ASDC_REFERENCE";
+ public static final String SCHEMA_SDNCTL = "SDNCTL";
+ public static final String GETARTIFACT = "getArtifact";
+ public static final String USER_ID = "userID";
+ public static final String ARTIFACT_TYPE = "artifact-type";
+ public static final String STATUS = "status";
+ public static final String UPLOADARTIFACT = "uploadArtifact";
+ public static final String REQUETS_ID = "request-id";
+ public static final String REQUEST_ACTION = "request-action";
+ public static final String SOURCE = "source";
+ public static final String DESIGN_SERVICE_PROPERTIES = "designService.properties";
+ public static final String DESIGN_TOOL = "Design-tool";
+ public static final String TECHNOLOGY = "technology";
+ public static final String PROTOCOL = "protocol";
+ public static final String SETPROTOCOLREFERENCE = "setProtocolReference";
+ public static final String ACTION_LEVEL = "action-level";
+ public static final String TEMPLATE = "template";
+ public static final String SETINCART = "setInCart";
+ public static final String INCART = "inCart";
+ public static final String STOREPASSWORD = "storeProperty";
+ public static final String INSTAR_V4_ADDRESS = "v4IPAddress";
+ public static final String INSTAR_V6_ADDRESS = "v6IPAddress";
+ public static final String INSTAR_V4_MASK = "v4Subnet";
+ public static final String INSTAR_V6_MASK = "v6Subnet";
+
+ private DesignServiceConstants() {
+ }
-
- public static final String DB_DT_ARTIFACT_TRACKING = "DT_ARTIFACT_TRACKING";
- public static final String DB_SDC_REFERENCE = "ASDC_REFERENCE";
- public static final String SCHEMA_SDNCTL = "SDNCTL";
- public static final String GETARTIFACT = "getArtifact";
- public static final String USER_ID = "userID";
- public static final String ARTIFACT_TYPE = "artifact-type";
- public static final String STATUS = "status";
- public static final String UPLOADARTIFACT = "uploadArtifact";
- public static final String REQUETS_ID = "request-id";
- public static final String REQUEST_ACTION = "request-action";
- public static final String SOURCE = "source";
- public static final String DESIGN_SERVICE_PROPERTIES = "designService.properties";
- public static final String DESIGN_TOOL = "Design-tool";
- public static final String TECHNOLOGY = "technology";
- public static final String PROTOCOL = "protocol";
- public static final String SETPROTOCOLREFERENCE = "setProtocolReference";
- public static final String ACTION_LEVEL = "action-level";
- public static final String TEMPLATE = "template";
- public static final String SETINCART = "setInCart";
- public static final String INCART = "inCart";
- public static final String STOREPASSWORD = "storeProperty";
- public static final String INSTAR_V4_ADDRESS = "v4IPAddress";
- public static final String INSTAR_V6_ADDRESS = "v6IPAddress";
- public static final String INSTAR_V4_MASK = "v4Subnet";
- public static final String INSTAR_V6_MASK = "v6Subnet";
+ public static String getEnvironmentVariable(String env) {
+ return System.getenv(env);
}
+} \ No newline at end of file
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/services/util/ArtifactHandlerClientTest.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/services/util/ArtifactHandlerClientTest.java
index b5f219067..a23956f18 100644
--- a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/services/util/ArtifactHandlerClientTest.java
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/services/util/ArtifactHandlerClientTest.java
@@ -21,19 +21,65 @@
package org.onap.appc.design.services.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.Properties;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({DesignServiceConstants.class})
public class ArtifactHandlerClientTest {
@Rule
public ExpectedException expectedEx = ExpectedException.none();
+ @Before
+ public void setup() throws NoSuchAlgorithmException, KeyManagementException {
+ PowerMockito.mockStatic(DesignServiceConstants.class);
+ }
+
@Test
public void testConstructorException() throws IOException {
expectedEx.expect(IOException.class);
new ArtifactHandlerClient();
}
+
+ @Test
+ public void testConstructor() throws IOException {
+ PowerMockito.when(DesignServiceConstants.getEnvironmentVariable(ArtifactHandlerClient.SDNC_CONFIG_DIR_VAR))
+ .thenReturn("src/test/resources");
+ ArtifactHandlerClient client = new ArtifactHandlerClient();
+ assertTrue(client instanceof ArtifactHandlerClient);
+ Properties props = Whitebox.getInternalState(client, "props");
+ assertTrue(props.containsKey("appc.upload.provider.url"));
+ }
+
+ @Test
+ public void testCreateArtifactData() throws IOException {
+ PowerMockito.when(DesignServiceConstants.getEnvironmentVariable(ArtifactHandlerClient.SDNC_CONFIG_DIR_VAR))
+ .thenReturn("src/test/resources");
+ ArtifactHandlerClient client = new ArtifactHandlerClient();
+ assertEquals("{\"input\": {\"request-information\":{\"request-id\":\"\",\"request-action\":"
+ + "\"StoreSdcDocumentRequest\",\"source\":\"Design-tool\"},\"document-parameters\":"
+ + "{\"artifact-version\":\"TEST\",\"artifact-name\":\"TEST\",\"artifact-contents\":"
+ + "\"TEST\"}}}", client.createArtifactData("{\"" + DesignServiceConstants.ARTIFACT_NAME
+ + "\":\"TEST\", \"" + DesignServiceConstants.ARTIFACT_VERSOIN + "\":\"TEST\", \"" +
+ DesignServiceConstants.ARTIFACT_CONTENTS + "\":\"TEST\"}", ""));
+ }
}