aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-design-services/provider/src/test/java/org/onap
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/test/java/org/onap
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/test/java/org/onap')
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/services/util/ArtifactHandlerClientTest.java46
1 files changed, 46 insertions, 0 deletions
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\"}", ""));
+ }
}