aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java')
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java
index 7e72b852..0a0e5fa0 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java
@@ -20,11 +20,11 @@
package org.onap.policy.distribution.main.startstop;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertThrows;
import org.junit.Test;
-import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.PolicyDistributionRuntimeException;
/**
@@ -36,6 +36,12 @@ import org.onap.policy.distribution.main.PolicyDistributionRuntimeException;
public class TestDistributionCommandLineArguments {
@Test
+ public void testDistributionOnlyFileName() {
+ String[] testArgs = {"src/test/resources/parameters/DistributionConfigParameters.json"};
+ assertThrows(PolicyDistributionRuntimeException.class, () -> new DistributionCommandLineArguments(testArgs));
+ }
+
+ @Test
public void testDistributionCommandLineArgumentsException() {
String[] wrongParams = {"arg1", "nothing", "{\"someJson\":1}"};
assertThrows(PolicyDistributionRuntimeException.class, () -> new DistributionCommandLineArguments(wrongParams));
@@ -44,28 +50,32 @@ public class TestDistributionCommandLineArguments {
@Test
public void testValidateFileNameEmpty() {
String[] argsOnlyKeyNoValue = {"-c", ""};
- assertValidate(argsOnlyKeyNoValue, "policy distribution configuration file was not specified as an argument");
+ assertValidate(argsOnlyKeyNoValue, "policy-distribution configuration file was not specified as an argument");
}
@Test
public void testValidateFileNameDoesNotExist() {
String[] fileNameNotExistentArgs = {"-c", "someFileName.json"};
assertValidate(fileNameNotExistentArgs,
- "policy distribution configuration file \"someFileName.json\" does not exist");
+ "policy-distribution configuration file \"someFileName.json\" does not exist");
}
@Test
public void testValidateFileNameIsNotFile() {
String[] folderAsFileNameArgs = {"-c", "src/test/resources/parameters"};
assertValidate(folderAsFileNameArgs,
- "policy distribution configuration file \"src/test/resources/parameters\" is not a normal file");
+ "policy-distribution configuration file \"src/test/resources/parameters\" is not a normal file");
}
- protected void assertValidate(String[] testArgs, String expectedErrorMsg) {
+ @Test
+ public void testDistributionVersion() {
+ String[] testArgs = {"-v"};
DistributionCommandLineArguments sutArgs = new DistributionCommandLineArguments(testArgs);
+ assertThat(sutArgs.version()).startsWith("ONAP Policy Framework Distribution Service");
+ }
- assertThatThrownBy(() -> sutArgs.validate())
- .isInstanceOf(PolicyDistributionException.class)
- .hasMessage(expectedErrorMsg);
+ private void assertValidate(String[] testArgs, String expectedErrorMsg) {
+ DistributionCommandLineArguments sutArgs = new DistributionCommandLineArguments(testArgs);
+ assertThatThrownBy(() -> sutArgs.validate()).hasMessage(expectedErrorMsg);
}
}