diff options
author | Jim Hahn <jrh3@att.com> | 2020-07-21 09:55:38 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-07-21 16:25:53 -0400 |
commit | 248a660d61fa03caa4710cf8cfe144eb245b807b (patch) | |
tree | 9f7c9aa7fda6d9ab9977bf2398a0136a787dc62a /models-interactions/model-impl/rest | |
parent | f203526d0f86d385976da394bd1f0f918e4445d9 (diff) |
Fix some sonars in policy-models
Fixed the following sonar issues in some of the project directories:
- use assertNull, assertEquals, etc.
- swap assertEquals arguments
- extract a constant
- don't invoke toString() in logger calls
- TODOs
- generic types
Issue-ID: POLICY-2714
Change-Id: Id8803f9bf617ea9fc173a67b8606600709b55bdc
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-impl/rest')
-rw-r--r-- | models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java index 52c0912e3..21df853f4 100644 --- a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java +++ b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * rest * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,6 +22,7 @@ package org.onap.policy.rest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.lang.annotation.Documented; @@ -146,55 +147,55 @@ public class RestTest { Pair<Integer, String> result = mgr.get(getUri, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("GOT: " + EXPECT_STRING, result.getRight()); result = mgr.delete(deleteUri, null, null, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + EXPECT_STRING, result.getRight()); result = mgr.delete(deleteUri, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + EXPECT_STRING, result.getRight()); result = mgr.put(putUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.put(putUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.post(postUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.post(postUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.patch(patchUri, null, null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.patch(patchUriBlank, null, null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight()); @@ -207,49 +208,49 @@ public class RestTest { Pair<Integer, String> result = mgr.get(getUri, "", null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("GOT: " + EXPECT_STRING, result.getRight()); result = mgr.delete(deleteUri, "", null, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + EXPECT_STRING, result.getRight()); result = mgr.put(putUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.put(putUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.post(postUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.post(postUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.patch(patchUri, "", null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.patch(patchUriBlank, "", null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight()); @@ -262,49 +263,49 @@ public class RestTest { Pair<Integer, String> result = mgr.get(getUri, "user", null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("GOT: " + EXPECT_STRING, result.getRight()); result = mgr.delete(deleteUri, "user", null, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + EXPECT_STRING, result.getRight()); result = mgr.put(putUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.put(putUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.post(postUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.post(postUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.patch(patchUri, "user", null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.patch(patchUriBlank, "user", null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight()); @@ -339,33 +340,33 @@ public class RestTest { Pair<Integer, String> result = mgr.get(baseUri + "RestTest/GetHello/" + NAME_PARAM, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("GOT: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); result = mgr.delete(baseUri + "RestTest/DeleteHello/" + NAME_PARAM, null, null, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); result = mgr.put(baseUri + "RestTest/PutHello/" + NAME_PARAM, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); result = mgr.post(baseUri + "RestTest/PostHello/" + NAME_PARAM, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); result = mgr.patch(baseUri + "RestTest/PatchHello/" + NAME_PARAM, null, null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); |