Skip to content

Commit b806219

Browse files
author
rathnapandi
committed
- Add junit test
1 parent 1cf89e3 commit b806219

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

modules/apis/src/main/java/com/axway/apim/apiimport/lib/cli/CLIAPIImportDatOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void printUsage(String message, String[] args) {
6060

6161
@Override
6262
protected String getAppName() {
63-
return "API-Import";
63+
return "API-Import Dat";
6464
}
6565

6666
@Override
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.axway.apim.apiimport.lib.cli;
2+
3+
import com.axway.apim.apiimport.lib.params.APIImportDatParams;
4+
import com.axway.apim.lib.CLIOptions;
5+
import com.axway.apim.lib.error.AppException;
6+
import org.testng.Assert;
7+
import org.testng.annotations.Test;
8+
9+
import java.io.ByteArrayOutputStream;
10+
import java.io.PrintStream;
11+
12+
public class APIImportDatCLIOptionsTest {
13+
14+
@Test
15+
public void testAPIImportDatParameter() throws AppException {
16+
String[] args = {"-s", "prod", "-a", "api-export.dat", "-orgName", "API Development", "-datPassword", "changeme"};
17+
CLIOptions options = CLIAPIImportDatOptions.create(args);
18+
APIImportDatParams params = (APIImportDatParams) options.getParams();
19+
Assert.assertEquals(params.getUsername(), "apiadmin");
20+
Assert.assertEquals(params.getPassword(), "changeme");
21+
Assert.assertEquals(params.getAPIManagerURL().toString(), "https://localhost:8075");
22+
Assert.assertEquals(params.getApiDefinition(), "api-export.dat");
23+
Assert.assertEquals(params.getOrgName(), "API Development");
24+
Assert.assertEquals(params.getDatPassword(), "changeme");
25+
}
26+
27+
@Test
28+
public void testAPIImportDatParameterWithoutPassword() throws AppException {
29+
String[] args = {"-s", "prod", "-a", "api-export.dat", "-orgName", "API Development"};
30+
CLIOptions options = CLIAPIImportDatOptions.create(args);
31+
APIImportDatParams params = (APIImportDatParams) options.getParams();
32+
Assert.assertEquals(params.getUsername(), "apiadmin");
33+
Assert.assertEquals(params.getPassword(), "changeme");
34+
Assert.assertEquals(params.getAPIManagerURL().toString(), "https://localhost:8075");
35+
Assert.assertEquals(params.getApiDefinition(), "api-export.dat");
36+
Assert.assertEquals(params.getOrgName(), "API Development");
37+
Assert.assertNull(params.getDatPassword());
38+
}
39+
40+
@Test
41+
public void testPrintUsage() throws AppException {
42+
PrintStream old = System.out;
43+
String[] args = {"-s", "prod", "-a", "api-export.dat", "-orgName", "API Development"};
44+
CLIOptions options = CLIAPIImportDatOptions.create(args);
45+
options.printUsage("test", args);
46+
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
47+
System.setOut(new PrintStream(byteArrayOutputStream));
48+
options.printUsage("test", args);
49+
System.setOut(old);
50+
Assert.assertTrue(byteArrayOutputStream.toString().contains("import-dat"));
51+
52+
}
53+
}

0 commit comments

Comments
 (0)