aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestReadArtifact.java
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2018-11-29 15:57:37 +0000
committerJoss Armstrong <joss.armstrong@ericsson.com>2018-11-30 15:04:39 +0000
commit22bfb9781932af06ac88d540aa667986e8592140 (patch)
treed9319802a48211bf18bb5cd78daaa748f4d21a0a /appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestReadArtifact.java
parent93cb989bb80197a1e6db289d4fc58a7ef6d48216 (diff)
Fix for APPC-1263
Removal of unused code. Refactoring of duplicated code and replacement with FileUtils library function and adding test case for ArtifactTransformer Issue-ID: APPC-1263 Change-Id: I4eab0cefa09620bae18c08ec2c4307d54dddd872 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestReadArtifact.java')
-rw-r--r--appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestReadArtifact.java39
1 files changed, 12 insertions, 27 deletions
diff --git a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestReadArtifact.java b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestReadArtifact.java
index 97a2458ed..697b90b07 100644
--- a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestReadArtifact.java
+++ b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestReadArtifact.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2018 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,26 +25,26 @@
package org.onap.sdnc.config.params.transformer.tosca;
-import java.io.BufferedReader;
-import java.io.FileInputStream;
+import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Test;
import org.onap.sdnc.config.params.data.PropertyDefinition;
import org.onap.sdnc.config.params.transformer.tosca.exceptions.ArtifactProcessorException;
public class TestReadArtifact {
+
@Test
public void testReadArtifactPositive() throws ArtifactProcessorException, IOException {
-
- String toscaArtifact = getFileContent("tosca/ReadArtifactPositiveInputTosca.yml");
+ String toscaArtifact = FileUtils.readFileToString(
+ new File("src/test/resources/tosca/ReadArtifactPositiveInputTosca.yml"),
+ StandardCharsets.UTF_8);
ArtifactProcessorImpl artifact = new ArtifactProcessorImpl();
PropertyDefinition ouptPD = artifact.readArtifact(toscaArtifact);
Assert.assertEquals(ouptPD.getKind(), "Property Definition");
Assert.assertEquals(ouptPD.getVersion(), "V1");
-
Assert.assertEquals(ouptPD.getParameters().get(0).getDefaultValue(), "0.0.0.0");
Assert.assertEquals(ouptPD.getParameters().get(0).getName(), "abc");
Assert.assertEquals(ouptPD.getParameters().get(0).getSource(), "source");
@@ -62,7 +64,6 @@ public class TestReadArtifact {
"address-0");
Assert.assertEquals(
ouptPD.getParameters().get(0).getResponseKeys().get(0).getFieldKeyName(), "0");
-
Assert.assertEquals(ouptPD.getParameters().get(1).getDefaultValue(), "value");
Assert.assertEquals(ouptPD.getParameters().get(1).getName(), "param 2");
Assert.assertEquals(ouptPD.getParameters().get(1).getSource(), "source");
@@ -84,13 +85,13 @@ public class TestReadArtifact {
ouptPD.getParameters().get(1).getResponseKeys().get(0).getUniqueKeyValue(), "0");
Assert.assertEquals(
ouptPD.getParameters().get(1).getResponseKeys().get(0).getFieldKeyName(), "0");
-
}
@Test
public void testReadArtifactNegetive() throws IOException {
-
- String toscaArtifact = getFileContent("tosca/ReadArtifactNegetiveInputTosca.yml");
+ String toscaArtifact = FileUtils.readFileToString(
+ new File("src/test/resources/tosca/ReadArtifactNegetiveInputTosca.yml"),
+ StandardCharsets.UTF_8);
ArtifactProcessorImpl artifact = new ArtifactProcessorImpl();
try {
PropertyDefinition ouptPD = artifact.readArtifact(toscaArtifact);
@@ -101,20 +102,4 @@ public class TestReadArtifact {
}
}
- private String getFileContent(String fileName) throws IOException {
- ClassLoader classLoader = new TestReadArtifact().getClass().getClassLoader();
- InputStream is = new FileInputStream(classLoader.getResource(fileName).getFile());
- BufferedReader buf = new BufferedReader(new InputStreamReader(is));
- String line = buf.readLine();
- StringBuilder sb = new StringBuilder();
-
- while (line != null) {
- sb.append(line).append("\n");
- line = buf.readLine();
- }
- String fileString = sb.toString();
- is.close();
- return fileString;
- }
-
}