aboutsummaryrefslogtreecommitdiffstats
path: root/client/client-editor
diff options
context:
space:
mode:
Diffstat (limited to 'client/client-editor')
-rw-r--r--client/client-editor/pom.xml2
-rw-r--r--client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/ApexEditorStartupTest.java118
-rw-r--r--client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/ApexEditorRestResourceTest.java201
-rw-r--r--client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeansTest.java31
4 files changed, 74 insertions, 278 deletions
diff --git a/client/client-editor/pom.xml b/client/client-editor/pom.xml
index 4057969ad..ace0c1042 100644
--- a/client/client-editor/pom.xml
+++ b/client/client-editor/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.apex-pdp.client</groupId>
<artifactId>apex-client</artifactId>
- <version>2.4.0-SNAPSHOT</version>
+ <version>2.4.1-SNAPSHOT</version>
</parent>
<artifactId>apex-client-editor</artifactId>
diff --git a/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/ApexEditorStartupTest.java b/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/ApexEditorStartupTest.java
index fdf1e804a..4d6c93222 100644
--- a/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/ApexEditorStartupTest.java
+++ b/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/ApexEditorStartupTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.apex.client.editor.rest;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -70,14 +71,9 @@ public class ApexEditorStartupTest {
public void testBadArg0() throws IOException, InterruptedException {
final String[] args = new String[] { "12321" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getLocalizedMessage().startsWith(
- "Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED) parameter error,"
- + " too many command line arguments specified : [12321]"));
- }
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
+ + " parameter error, too many command line arguments specified : [12321]");
}
/**
@@ -90,14 +86,9 @@ public class ApexEditorStartupTest {
public void testBadArg1() throws IOException, InterruptedException {
final String[] args = new String[] { "12321 12322 12323" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getLocalizedMessage().startsWith(
- "Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED) parameter error,"
- + " too many command line arguments specified : [12321 12322 12323]"));
- }
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
+ + " parameter error, too many command line arguments specified : [12321 12322 12323]");
}
/**
@@ -110,14 +101,9 @@ public class ApexEditorStartupTest {
public void testBadArg2() throws IOException, InterruptedException {
final String[] args = new String[] { "-z" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getLocalizedMessage().startsWith(
- "Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED) parameter error,"
- + " invalid command line arguments specified : Unrecognized option: -z"));
- }
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
+ + " parameter error, invalid command line arguments specified : Unrecognized option: -z");
}
/**
@@ -130,14 +116,9 @@ public class ApexEditorStartupTest {
public void testBadArg3() throws IOException, InterruptedException {
final String[] args = new String[] { "--hello" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getLocalizedMessage().startsWith(
- "Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED) parameter error,"
- + " invalid command line arguments specified : Unrecognized option: --hello"));
- }
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
+ + " parameter error, invalid command line arguments specified : Unrecognized option: --hello");
}
@@ -151,16 +132,11 @@ public class ApexEditorStartupTest {
public void testBadArg4() throws IOException, InterruptedException {
final String[] args = new String[] { "-l", "+++++" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getLocalizedMessage()
- .startsWith("Apex Editor REST endpoint (ApexEditorMain: "
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: "
+ "Config=[ApexEditorParameters: URI=http://+++++:18989/apexservices/, TTL=-1sec], "
+ "State=STOPPED) parameters invalid, listen address is not valid. "
- + "Illegal character in hostname at index 7: http://+++++:18989/apexservices/"));
- }
+ + "Illegal character in hostname at index 7: http://+++++:18989/apexservices/");
}
/**
@@ -173,13 +149,8 @@ public class ApexEditorStartupTest {
public void testHelp0() throws IOException, InterruptedException {
final String[] args = new String[] { "--help" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage()
- .startsWith("usage: org.onap.policy.apex.client.editor.rest.ApexEditorMain [options...]"));
- }
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("usage: org.onap.policy.apex.client.editor.rest.ApexEditorMain [options...]");
}
/**
@@ -192,13 +163,8 @@ public class ApexEditorStartupTest {
public void testHelp1() throws IOException, InterruptedException {
final String[] args = new String[] { "-h" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage()
- .startsWith("usage: org.onap.policy.apex.client.editor.rest.ApexEditorMain [options...]"));
- }
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("usage: org.onap.policy.apex.client.editor.rest.ApexEditorMain [options...]");
}
/**
@@ -258,14 +224,9 @@ public class ApexEditorStartupTest {
public void testPortArgSpace() throws IOException, InterruptedException {
final String[] args = new String[] { "-p 12321" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage().startsWith(
- "Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED) parameter error,"
- + " error parsing argument \"port\" :For input string: \" 12321\""));
- }
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: Config=[null], State=STOPPED)"
+ + " parameter error, error parsing argument \"port\" :For input string: \" 12321\"");
}
/**
@@ -278,15 +239,10 @@ public class ApexEditorStartupTest {
public void testBadPortArgs0() throws IOException, InterruptedException {
final String[] args = new String[] { "-p0" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage()
- .startsWith("Apex Editor REST endpoint (ApexEditorMain: "
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: "
+ "Config=[ApexEditorParameters: URI=http://localhost:0/apexservices/, TTL=-1sec], "
- + "State=STOPPED) parameters invalid, port must be between 1024 and 65535"));
- }
+ + "State=STOPPED) parameters invalid, port must be between 1024 and 65535");
}
/**
@@ -299,15 +255,10 @@ public class ApexEditorStartupTest {
public void testBadPortArgs1023() throws IOException, InterruptedException {
final String[] args = new String[] { "-p1023" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage()
- .startsWith("Apex Editor REST endpoint (ApexEditorMain: "
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: "
+ "Config=[ApexEditorParameters: URI=http://localhost:1023/apexservices/, TTL=-1sec], "
- + "State=STOPPED) parameters invalid, port must be between 1024 and 65535"));
- }
+ + "State=STOPPED) parameters invalid, port must be between 1024 and 65535");
}
/**
@@ -320,15 +271,10 @@ public class ApexEditorStartupTest {
public void testBadPortArgs65536() throws IOException, InterruptedException {
final String[] args = new String[] { "-p65536" };
- try {
- runEditor(args);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage()
- .startsWith("Apex Editor REST endpoint (ApexEditorMain: "
+ assertThatThrownBy(() -> runEditor(args)).isInstanceOf(ApexEditorParameterException.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexEditorMain: "
+ "Config=[ApexEditorParameters: URI=http://localhost:65536/apexservices/, TTL=-1sec], "
- + "State=STOPPED) parameters invalid, port must be between 1024 and 65535"));
- }
+ + "State=STOPPED) parameters invalid, port must be between 1024 and 65535");
}
/**
diff --git a/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/ApexEditorRestResourceTest.java b/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/ApexEditorRestResourceTest.java
index 642628f97..ace427052 100644
--- a/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/ApexEditorRestResourceTest.java
+++ b/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/ApexEditorRestResourceTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.apex.client.editor.rest.handling;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -60,11 +61,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
final int corruptSessionId = ApexEditorRestResource.createCorruptSession();
- try {
- target("editor/" + corruptSessionId + "/Model/Analyse").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Model/Analyse").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/Model/Analyse").request().get(ApexApiResult.class);
assertEquals(Result.SUCCESS, result.getResult());
@@ -73,11 +70,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/12345/Model/Analyse").request().get(ApexApiResult.class);
assertEquals(Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Model/Validate").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Model/Validate").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/Model/Validate").request().get(ApexApiResult.class);
assertEquals(Result.FAILED, result.getResult());
@@ -99,11 +92,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Model/Create").request().post(csEntity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Model/Create").request().post(csEntity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Model/Create").request().post(csEntity, ApexApiResult.class);
result = target("editor/-12345/Model/Update").request().put(csEntity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -114,17 +103,9 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Model/Update").request().put(csEntity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Model/Update").request().put(csEntity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Model/Update").request().put(csEntity, ApexApiResult.class);
- try {
- result = target("editor/" + corruptSessionId + "/Model/GetKey").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ result = target("editor/" + corruptSessionId + "/Model/GetKey").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/Model/GetKey").request().get(ApexApiResult.class);
assertEquals(Result.SUCCESS, result.getResult());
@@ -133,11 +114,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/12345/Model/GetKey").request().get(ApexApiResult.class);
assertEquals(Result.FAILED, result.getResult());
- try {
- result = target("editor/" + corruptSessionId + "/Model/Get").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ result = target("editor/" + corruptSessionId + "/Model/Get").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/Model/Get").request().get(ApexApiResult.class);
assertEquals(Result.SUCCESS, result.getResult());
@@ -158,11 +135,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
resultString = target("editor/12345/Model/Download").request().get(String.class);
assertEquals("", resultString);
- try {
- result = target("editor/" + corruptSessionId + "/KeyInformation/Get").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ result = target("editor/" + corruptSessionId + "/KeyInformation/Get").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/KeyInformation/Get").request().get(ApexApiResult.class);
assertEquals(Result.SUCCESS, result.getResult());
@@ -171,11 +144,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/12345/KeyInformation/Get").request().get(ApexApiResult.class);
assertEquals(Result.FAILED, result.getResult());
- try {
- result = target("editor/" + corruptSessionId + "/Model/Delete").request().delete(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ result = target("editor/" + corruptSessionId + "/Model/Delete").request().delete(ApexApiResult.class);
result = target("editor/" + sessionId + "/Model/Delete").request().delete(ApexApiResult.class);
assertEquals(Result.SUCCESS, result.getResult());
@@ -196,11 +165,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/-12345/Validate/ContextSchema").request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Validate/ContextSchema").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Validate/ContextSchema").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/Validate/ContextSchema").request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
@@ -232,12 +197,8 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/ContextSchema/Get").queryParam("name", (String) null)
+ target("editor/" + corruptSessionId + "/ContextSchema/Get").queryParam("name", (String) null)
.queryParam("version", (String) null).request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
String csString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ "\"schemaFlavour\" : \"Java\"," + "\"schemaDefinition\" : \"java.lang.String\","
@@ -251,12 +212,9 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/ContextSchema/Create").request().post(csEntity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/ContextSchema/Create").request().post(csEntity,
+ target("editor/" + corruptSessionId + "/ContextSchema/Create").request().post(csEntity,
ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+
csString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ "\"schemaFlavour\" : \"Java\"," + "\"schemaDefinition\" : \"my.perfect.String\","
@@ -270,11 +228,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/ContextSchema/Update").request().put(csEntity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/ContextSchema/Update").request().put(csEntity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/ContextSchema/Update").request().put(csEntity, ApexApiResult.class);
result = target("editor/" + sessionId + "/ContextSchema/Get").queryParam("name", "Hello")
.queryParam("version", (String) null).request().get(ApexApiResult.class);
@@ -289,23 +243,15 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/ContextSchema/Get").queryParam("name", "Hello")
+ target("editor/" + corruptSessionId + "/ContextSchema/Get").queryParam("name", "Hello")
.queryParam("version", (String) null).request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/" + sessionId + "/Validate/ContextSchema").queryParam("name", (String) null)
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/ContextSchema/Delete").queryParam("name", "Hello")
+ target("editor/" + corruptSessionId + "/ContextSchema/Delete").queryParam("name", "Hello")
.queryParam("version", "0.0.2").request().delete(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/-123345/ContextSchema/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
@@ -331,11 +277,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/-12345/Validate/ContextAlbum").request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Validate/ContextAlbum").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Validate/ContextAlbum").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/Validate/ContextAlbum").request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
@@ -380,11 +322,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/ContextAlbum/Create").request().post(caEntity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/ContextAlbum/Create").request().post(caEntity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/ContextAlbum/Create").request().post(caEntity, ApexApiResult.class);
caString = "{" + "\"name\" : \"Hello\"," + "\"version\" : \"0.0.2\","
+ "\"scope\" : \"Global\"," + "\"writeable\" : false,"
@@ -399,18 +337,10 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/ContextAlbum/Update").request().put(caEntity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/ContextAlbum/Update").request().put(caEntity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/ContextAlbum/Update").request().put(caEntity, ApexApiResult.class);
- try {
- target("editor/" + corruptSessionId + "/ContextAlbum/Get").queryParam("name", "Hello")
+ target("editor/" + corruptSessionId + "/ContextAlbum/Get").queryParam("name", "Hello")
.queryParam("version", (String) null).request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/" + sessionId + "/ContextAlbum/Get").queryParam("name", "Hello")
.queryParam("version", (String) null).request().get(ApexApiResult.class);
@@ -429,12 +359,8 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/ContextAlbum/Delete").queryParam("name", (String) null)
+ target("editor/" + corruptSessionId + "/ContextAlbum/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/-123345/ContextAlbum/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
@@ -464,11 +390,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Validate/Event").request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Validate/Event").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Validate/Event").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", (String) null)
.queryParam("version", (String) null).request().get(ApexApiResult.class);
@@ -511,11 +433,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Event/Create").request().post(entity, ApexApiResult.class);
entityString = "{" + "\"name\" : \"Hiya\"," + "\"version\" : \"0.0.2\","
+ "\"namespace\" : \"somewhere.over.the.rainbow\"," + "\"source\" : \"beginning\","
@@ -570,11 +488,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Event/Update").request().put(entity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Event/Update").request().put(entity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Event/Update").request().put(entity, ApexApiResult.class);
entityString = "{" + "\"name\" : null," + "\"version\" : \"0.0.2\","
+ "\"namespace\" : \"somewhere.over.someone.elses.rainbow\","
@@ -607,12 +521,8 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Event/Get").queryParam("name", "Hello")
+ target("editor/" + corruptSessionId + "/Event/Get").queryParam("name", "Hello")
.queryParam("version", (String) null).request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", (String) null)
.queryParam("version", (String) null).request().get(ApexApiResult.class);
@@ -624,12 +534,8 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Event/Delete").queryParam("name", (String) null)
+ target("editor/" + corruptSessionId + "/Event/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/-123345/Event/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
@@ -705,11 +611,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Task/Create").request().post(entity, ApexApiResult.class);
entityString = "{" + "\"name\" : \"Hiya\"," + "\"version\" : \"0.0.2\","
+ "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\","
@@ -896,11 +798,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Task/Update").request().put(entity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Task/Update").request().put(entity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Task/Update").request().put(entity, ApexApiResult.class);
entityString = "{" + "\"name\" : null," + "\"version\" : \"0.0.2\","
+ "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002671\","
@@ -932,12 +830,8 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Task/Get").queryParam("name", "Hello")
+ target("editor/" + corruptSessionId + "/Task/Get").queryParam("name", "Hello")
.queryParam("version", (String) null).request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", (String) null)
.queryParam("version", (String) null).request().get(ApexApiResult.class);
@@ -949,12 +843,8 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Task/Delete").queryParam("name", (String) null)
+ target("editor/" + corruptSessionId + "/Task/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/-123345/Task/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
@@ -984,12 +874,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Model/Validate").request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Model/Validate").request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
-
+ target("editor/" + corruptSessionId + "/Model/Validate").request().get(ApexApiResult.class);
result = target("editor/" + sessionId + "/Model/Validate").queryParam("name", (String) null)
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -1039,11 +924,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
result = target("editor/" + sessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Policy/Create").request().post(entity, ApexApiResult.class);
entityString = "{" + "\"name\" : \"GoodTaSeeYa\"," + "\"version\" : \"0.0.2\","
+ "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
@@ -1411,11 +1292,7 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.put(entity, ApexApiResult.class);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Policy/Update").request().put(entity, ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
+ target("editor/" + corruptSessionId + "/Policy/Update").request().put(entity, ApexApiResult.class);
entityString = "{" + "\"name\" : null," + "\"version\" : \"0.0.2\","
+ "\"template\" : \"somewhere.over.the.rainbow\"," + "\"firstState\" : \"state\","
@@ -1465,12 +1342,8 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Policy/Get").queryParam("name", "Hello")
+ target("editor/" + corruptSessionId + "/Policy/Get").queryParam("name", "Hello")
.queryParam("version", (String) null).request().get(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/" + sessionId + "/Validate/Event").queryParam("name", (String) null)
.queryParam("version", (String) null).request().get(ApexApiResult.class);
@@ -1482,12 +1355,8 @@ public class ApexEditorRestResourceTest extends JerseyTest {
.queryParam("version", (String) null).request().get(ApexApiResult.class);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- try {
- target("editor/" + corruptSessionId + "/Policy/Delete").queryParam("name", (String) null)
+ target("editor/" + corruptSessionId + "/Policy/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
- } catch (final Exception e) {
- assertEquals("HTTP 500 Request failed.", e.getMessage());
- }
result = target("editor/-123345/Policy/Delete").queryParam("name", (String) null)
.queryParam("version", (String) null).request().delete(ApexApiResult.class);
diff --git a/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeansTest.java b/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeansTest.java
index ba773b1ac..bdf47fedc 100644
--- a/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeansTest.java
+++ b/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeansTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +21,9 @@
package org.onap.policy.apex.client.editor.rest.handling.bean;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
import org.junit.Test;
@@ -60,29 +61,9 @@ public class BeansTest {
assertNull(beanFake.get("name"));
assertNull(beanFake.get("field1"));
- try {
- beanFake.get("iDontExist");
- fail("test should throw an exception here");
- } catch (final IllegalArgumentException e) {
- assertNotNull(e);
- }
- try {
- beanFake.get("nome");
- fail("test should throw an exception here");
- } catch (final IllegalArgumentException e) {
- assertNotNull(e);
- }
- try {
- beanFake.get("field2");
- fail("test should throw an exception here");
- } catch (final IllegalArgumentException e) {
- assertNotNull(e);
- }
- try {
- beanFake.get("field3");
- fail("test should throw an exception here");
- } catch (final IllegalArgumentException e) {
- assertNotNull(e);
- }
+ assertThatThrownBy(() -> beanFake.get("iDontExist")).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> beanFake.get("nome")).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> beanFake.get("field2")).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> beanFake.get("field3")).isInstanceOf(IllegalArgumentException.class);
}
}