summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common/src/test/java
diff options
context:
space:
mode:
authorDominik Mizyn <d.mizyn@samsung.com>2019-05-29 12:22:27 +0200
committerDominik Mizyn <d.mizyn@samsung.com>2019-05-29 16:37:08 +0200
commit788e99d836a75badf45dce96358d184aa9e549f2 (patch)
treed10fa98f8e0a162c2488f2d32bf67b280ad958d5 /ecomp-portal-BE-common/src/test/java
parentba546e970d779a5e87a07b3058a85e1446c39129 (diff)
Sonar: Reduce cyclomatic complexity
Reduce the number of conditional operators for equals(). Improve testEquals() to better cover this method. This patch also: * immediately returns expression instead of assigning it to the temporary variable "str", * adds the "@Override" annotation above equals() method signature. Issue-ID: PORTAL-595 Change-Id: I15f600acce873eb3f22cc405d06a50890c7e87c3 Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
Diffstat (limited to 'ecomp-portal-BE-common/src/test/java')
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java
index 2cc03a60..0923d033 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java
@@ -121,10 +121,9 @@ public class EPUserAppTest {
}
-
+
@Test
public void testEquals(){
-
EPRole epRole = new EPRole();
epRole.setId((long) 12345);
epRole.setName("test");
@@ -132,19 +131,22 @@ public class EPUserAppTest {
epRole.setPriority(1);
epRole.setAppId((long)1);
epRole.setAppRoleId((long)1);
-
+
EPUserApp user1 = mockEPUserApp();
user1.setApp(mockEPApp());
user1.setRole(epRole);
-
+
EPUserApp user2 = mockEPUserApp();
user2.setApp(mockEPApp());
user2.setRole(epRole);
-
+
+ EPUserApp nullUser = null;
+
+ assertTrue(user1.equals(user1));
+ assertFalse(user1.equals(nullUser));
+ assertFalse(user1.equals(Long.valueOf(1)));
assertTrue(user1.equals(user2));
-
}
-
private EPApp mockEPApp() {
EPApp epApp = new EPApp();
epApp.setId((long) 12345);