diff options
author | 2017-12-18 19:20:35 -0600 | |
---|---|---|
committer | 2017-12-19 15:47:04 +0000 | |
commit | b1c754c49e15e7fad854ee8c678d53be8d40e30e (patch) | |
tree | d28dd4f852d94b447ee42d7ba634ec623329f5e6 /appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestGenerateArtifactString.java | |
parent | 17c2c59a3301cdc969fe53a9de8e0d84d4163b9e (diff) |
Update appc-config-parms to use onap packaging
Issue-ID: APPC-13
Change-Id: I490847faabfed2e977ee21c0157adf8a790cea65
Signed-off-by: Takamune Cho <tc012c@att.com>
Diffstat (limited to 'appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestGenerateArtifactString.java')
-rw-r--r-- | appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestGenerateArtifactString.java | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestGenerateArtifactString.java b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestGenerateArtifactString.java index 4ffbe5298..fb5e934ad 100644 --- a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestGenerateArtifactString.java +++ b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestGenerateArtifactString.java @@ -22,18 +22,23 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.sdnc.config.params.transformer.tosca; - +package org.onap.sdnc.config.params.transformer.tosca; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.openecomp.sdnc.config.params.transformer.tosca.exceptions.ArtifactProcessorException; - -import java.io.*; -import java.net.URL; +import org.onap.sdnc.config.params.transformer.tosca.exceptions.ArtifactProcessorException; -public class TestGenerateArtifactString{ +public class TestGenerateArtifactString { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -42,58 +47,56 @@ public class TestGenerateArtifactString{ public void testStringArtifactGenerator() throws IOException, ArtifactProcessorException { String pdString = getFileContent("tosca/ExamplePropertyDefinition.yml"); - OutputStream outstream=null; + OutputStream outstream = null; File tempFile = temporaryFolder.newFile("TestTosca.yml"); outstream = new FileOutputStream(tempFile); ArtifactProcessorImpl arp = new ArtifactProcessorImpl(); - arp.generateArtifact(pdString,outstream); + arp.generateArtifact(pdString, outstream); outstream.flush(); outstream.close(); String expectedTosca = getFileContent("tosca/ExpectedTosca.yml"); String toscaString = getFileContent(tempFile); - Assert.assertEquals(expectedTosca,toscaString); + Assert.assertEquals(expectedTosca, toscaString); } @Test - public void testArtifactGeneratorWithParameterNameBlank() throws IOException, ArtifactProcessorException { + public void testArtifactGeneratorWithParameterNameBlank() + throws IOException, ArtifactProcessorException { String pdString = getFileContent("tosca/ExamplePropertyDefinition2.yml"); - OutputStream outstream=null; - String expectedMsg ="Parameter name is empty,null or contains whitespace"; + OutputStream outstream = null; + String expectedMsg = "Parameter name is empty,null or contains whitespace"; File tempFile = temporaryFolder.newFile("TestTosca.yml"); outstream = new FileOutputStream(tempFile); ArtifactProcessorImpl arp = new ArtifactProcessorImpl(); try { arp.generateArtifact(pdString, outstream); - } - catch (ArtifactProcessorException e) - { - Assert.assertEquals(expectedMsg,e.getMessage()); + } catch (ArtifactProcessorException e) { + Assert.assertEquals(expectedMsg, e.getMessage()); } outstream.flush(); outstream.close(); } @Test - public void testArtifactGeneratorWithParameterNameNull() throws IOException, ArtifactProcessorException { + public void testArtifactGeneratorWithParameterNameNull() + throws IOException, ArtifactProcessorException { String pdString = getFileContent("tosca/ExamplePropertyDefinition3.yml"); - OutputStream outstream=null; - String expectedMsg ="Parameter name is empty,null or contains whitespace"; + OutputStream outstream = null; + String expectedMsg = "Parameter name is empty,null or contains whitespace"; File tempFile = temporaryFolder.newFile("TestTosca.yml"); outstream = new FileOutputStream(tempFile); ArtifactProcessorImpl arp = new ArtifactProcessorImpl(); try { arp.generateArtifact(pdString, outstream); - } - catch (ArtifactProcessorException e) - { - Assert.assertEquals(expectedMsg,e.getMessage()); + } catch (ArtifactProcessorException e) { + Assert.assertEquals(expectedMsg, e.getMessage()); } outstream.flush(); outstream.close(); @@ -103,25 +106,22 @@ public class TestGenerateArtifactString{ public void testArtifactGeneratorWithKindNull() throws IOException, ArtifactProcessorException { String pdString = getFileContent("tosca/ExamplePropertyDefinition4.yml"); - OutputStream outstream=null; - String expectedMsg ="Kind in PropertyDefinition is blank or null"; + OutputStream outstream = null; + String expectedMsg = "Kind in PropertyDefinition is blank or null"; File tempFile = temporaryFolder.newFile("TestTosca.yml"); outstream = new FileOutputStream(tempFile); ArtifactProcessorImpl arp = new ArtifactProcessorImpl(); try { arp.generateArtifact(pdString, outstream); - } - catch (ArtifactProcessorException e) - { - Assert.assertEquals(expectedMsg,e.getMessage()); + } catch (ArtifactProcessorException e) { + Assert.assertEquals(expectedMsg, e.getMessage()); } outstream.flush(); outstream.close(); } - private String getFileContent(String fileName) throws IOException - { + private String getFileContent(String fileName) throws IOException { ClassLoader classLoader = new TestGenerateArtifactString().getClass().getClassLoader(); InputStream is = new FileInputStream(classLoader.getResource(fileName).getFile()); BufferedReader buf = new BufferedReader(new InputStreamReader(is)); @@ -137,8 +137,7 @@ public class TestGenerateArtifactString{ return fileString; } - private String getFileContent(File file) throws IOException - { + private String getFileContent(File file) throws IOException { InputStream is = new FileInputStream(file); BufferedReader buf = new BufferedReader(new InputStreamReader(is)); String line = buf.readLine(); |