summaryrefslogtreecommitdiffstats
path: root/appc-client/code-generator
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2017-09-26 17:39:23 +0530
committerPatrick Brady <pb071s@att.com>2017-09-27 22:05:22 +0000
commit5c0ab1dfa4aab9cd83d5baac17710963a11b22d9 (patch)
treef24a2e74e59afae15c49d4970573e0ec72120045 /appc-client/code-generator
parentf2e77cc8209018f6955fba400ab4d0ff609448b1 (diff)
Increased test coverage for appc-java-client
Added Junit test cases to increase test coverage for appc-java-client Change-Id: I31154acea348f50da5df47262611bfb108a4ed3a Issue-ID:APPC-223 Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'appc-client/code-generator')
-rw-r--r--appc-client/code-generator/pom.xml5
-rw-r--r--appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java14
-rw-r--r--appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/api/CLITest.java57
-rw-r--r--appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/impl/CodeGenWriterTest.java22
4 files changed, 91 insertions, 7 deletions
diff --git a/appc-client/code-generator/pom.xml b/appc-client/code-generator/pom.xml
index 92bc109ec..4a318ffe9 100644
--- a/appc-client/code-generator/pom.xml
+++ b/appc-client/code-generator/pom.xml
@@ -118,5 +118,10 @@
<artifactId>maven-core</artifactId>
<version>${maven.core.version}</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java
index 61516a72d..c748b7cca 100644
--- a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java
+++ b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java
@@ -36,29 +36,29 @@ public class CLI {
if(destinationFile == null)
throw new IllegalArgumentException("Destination file name is missing. Please add argument 'client "
+ sourceFile
- + "<destination> <model template> <builder> <conf file>'");
+ + " <destination> <model template> <builder> <conf file>'");
String templateFile = args[2];
if(templateFile == null)
throw new IllegalArgumentException("template file name is missing. Please add argument 'client "
+ sourceFile
- + destinationFile
+ + " "+destinationFile
+ " <model template> <builder> <conf file>'");
String builderName = args[3];
if(builderName == null)
throw new IllegalArgumentException("builder FQDN is missing. Please add argument 'client "
+ sourceFile
- + destinationFile
- + templateFile
+ + " "+destinationFile
+ + " "+templateFile
+ " <builder> <conf file>'");
String contextConfName = args[4];
if(contextConfName == null)
throw new IllegalArgumentException("context conf file is missing. Please add argument 'client "
+ sourceFile
- + destinationFile
- + templateFile
- + builderName
+ + " "+destinationFile
+ + " "+templateFile
+ + " "+builderName
+ " <conf file>'");
ModelGenerator generator = new ModelGenerator();
generator.execute(sourceFile, destinationFile, templateFile, builderName, contextConfName);
diff --git a/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/api/CLITest.java b/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/api/CLITest.java
new file mode 100644
index 000000000..3d6eb1bf3
--- /dev/null
+++ b/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/api/CLITest.java
@@ -0,0 +1,57 @@
+package org.openecomp.appc.tools.generator.api;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CLITest {
+ @Test
+ public void missingSourceFileTest() {
+ CLI cli = new CLI();
+ try {
+ String[] input = new String[1];
+ cli.main(input);
+ } catch (Exception e) {
+ Assert.assertEquals("Source file is missing. Please add argument 'client <source file> <destination file> <model template>'",e.getMessage());
+ }
+ }
+ @Test
+ public void missingDestinationFileTest() {
+ CLI cli = new CLI();
+ try {
+ String[] input = {"sourceFilePath",null};
+ cli.main(input);
+ } catch (Exception e) {
+ Assert.assertEquals("Destination file name is missing. Please add argument 'client sourceFilePath <destination> <model template> <builder> <conf file>'",e.getMessage());
+ }
+ }
+ @Test
+ public void missingTemplateFileTest() {
+ CLI cli = new CLI();
+ try {
+ String[] input = {"sourceFilePath","destinationPath",null};
+ cli.main(input);
+ } catch (Exception e) {
+ Assert.assertEquals("template file name is missing. Please add argument 'client sourceFilePath destinationPath <model template> <builder> <conf file>'",e.getMessage());
+ }
+ }
+ @Test
+ public void missingBuilderNameTest() {
+ CLI cli = new CLI();
+ try {
+ String[] input = {"sourceFilePath","destinationPath","templateFileName",null};
+ cli.main(input);
+ } catch (Exception e) {
+ Assert.assertEquals("builder FQDN is missing. Please add argument 'client sourceFilePath destinationPath templateFileName <builder> <conf file>'",e.getMessage());
+ }
+ }
+ @Test
+ public void missingContextConfFileNameTest() {
+ CLI cli = new CLI();
+ try {
+ String[] input = {"sourceFilePath","destinationPath","templateFileName","builderFQDN",null};
+ cli.main(input);
+ } catch (Exception e) {
+ Assert.assertEquals(e.getMessage(),"context conf file is missing. Please add argument 'client sourceFilePath destinationPath templateFileName builderFQDN <conf file>'");
+ }
+ }
+}
diff --git a/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/impl/CodeGenWriterTest.java b/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/impl/CodeGenWriterTest.java
new file mode 100644
index 000000000..84cca9337
--- /dev/null
+++ b/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/impl/CodeGenWriterTest.java
@@ -0,0 +1,22 @@
+package org.openecomp.appc.tools.generator.impl;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+
+
+public class CodeGenWriterTest {
+ @Test
+ public void writeTest() throws IOException {
+ CodeGenWriter codeGenWriter = new CodeGenWriter("destination");
+ char[] cbuf = {'t','e','s','t'};
+ int off = 1;
+ int len = 3;
+ codeGenWriter.write(cbuf,off,len);
+ codeGenWriter.flush();
+ codeGenWriter.close();
+ Assert.assertNotNull(codeGenWriter);
+ }
+
+}