diff options
author | asgar <sammoham@in.ibm.com> | 2018-09-26 17:58:17 +0530 |
---|---|---|
committer | asgar <sammoham@in.ibm.com> | 2018-09-26 17:58:23 +0530 |
commit | 4be6886a011ddbc4543e8c27b759a27ff3415c18 (patch) | |
tree | 7f742151b588b0130769b1c494d1046b4bd699a1 | |
parent | cfa6a7030d736083a074f878c00c238caacb3291 (diff) |
equals method covered in EPUserApp.java
Change-Id: Ib804ca53a4c308a3c2710acc2efdd351d103047a
Issue-ID: PORTAL-403
Signed-off-by: Mohamed Asgar Samiulla <sammoham@in.ibm.com>
-rw-r--r-- | ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java | 188 |
1 files changed, 116 insertions, 72 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 de752b94..61466269 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 @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modifications Copyright © 2018 IBM. + * ================================================================================ * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -46,77 +48,119 @@ import org.onap.portalapp.portal.domain.EPUserApp; public class EPUserAppTest { - public EPUserApp mockEPUserApp(){ - - EPApp epApp = new EPApp(); - epApp.setName("test"); - epApp.setImageUrl("test"); - epApp.setDescription("test"); - epApp.setNotes("test"); - epApp.setUrl("test"); - epApp.setAlternateUrl("test"); - epApp.setAppRestEndpoint("test"); - epApp.setMlAppName("test"); - epApp.setMlAppAdminId("test"); - epApp.setMotsId((long)1); - epApp.setUsername("test"); - epApp.setAppPassword("test"); - - - //Role - EPRole epRole = new EPRole(); - epRole.setName("test"); - epRole.setActive(false); - epRole.setPriority(1); - epRole.setAppId((long)1); - epRole.setAppRoleId((long)1); - - EPUserApp user = new EPUserApp(); - user.setUserId((long)1); - user.setApp(epApp); - user.setRole(epRole); - user.setPriority((short)32767); - - - return user; - } - - @Test - public void userTest(){ - EPUserApp user = mockEPUserApp(); - - EPApp epApp = new EPApp(); - epApp.setName("test"); - epApp.setImageUrl("test"); - epApp.setDescription("test"); - epApp.setNotes("test"); - epApp.setUrl("test"); - epApp.setAlternateUrl("test"); - epApp.setAppRestEndpoint("test"); - epApp.setMlAppName("test"); - epApp.setMlAppAdminId("test"); - epApp.setMotsId((long)1); - epApp.setUsername("test"); - epApp.setAppPassword("test"); - user.setApp(epApp); - - //Role - EPRole epRole = new EPRole(); - epRole.setName("test"); - epRole.setActive(false); - epRole.setPriority(1); - epRole.setAppId((long)1); - epRole.setAppRoleId((long)1); - - + public EPUserApp mockEPUserApp(){ + + EPApp epApp = new EPApp(); + epApp.setName("test"); + epApp.setImageUrl("test"); + epApp.setDescription("test"); + epApp.setNotes("test"); + epApp.setUrl("test"); + epApp.setAlternateUrl("test"); + epApp.setAppRestEndpoint("test"); + epApp.setMlAppName("test"); + epApp.setMlAppAdminId("test"); + epApp.setMotsId((long)1); + epApp.setUsername("test"); + epApp.setAppPassword("test"); + + + //Role + EPRole epRole = new EPRole(); + epRole.setName("test"); + epRole.setActive(false); + epRole.setPriority(1); + epRole.setAppId((long)1); + epRole.setAppRoleId((long)1); + + EPUserApp user = new EPUserApp(); + user.setUserId((long)1); + user.setApp(epApp); + user.setRole(epRole); + user.setPriority((short)32767); + + + return user; + } + + @Test + public void userTest(){ + EPUserApp user = mockEPUserApp(); + + EPApp epApp = new EPApp(); + epApp.setName("test"); + epApp.setImageUrl("test"); + epApp.setDescription("test"); + epApp.setNotes("test"); + epApp.setUrl("test"); + epApp.setAlternateUrl("test"); + epApp.setAppRestEndpoint("test"); + epApp.setMlAppName("test"); + epApp.setMlAppAdminId("test"); + epApp.setMotsId((long)1); + epApp.setUsername("test"); + epApp.setAppPassword("test"); + user.setApp(epApp); + + //Role + EPRole epRole = new EPRole(); + epRole.setName("test"); + epRole.setActive(false); + epRole.setPriority(1); + epRole.setAppId((long)1); + epRole.setAppRoleId((long)1); + + assertEquals(user.getUserId(),Long.valueOf(1)); - assertEquals(user.getApp(), epApp); - assertEquals(user.getPriority().getClass(), Short.class); - - assertEquals(user.toString(), "[u: 1; a: null, r: null; appRoleId: 1]"); - - assertEquals(user.hashCode(), user.hashCode()); - - - } + assertEquals(user.getApp(), epApp); + assertEquals(user.getPriority().getClass(), Short.class); + + assertEquals(user.toString(), "[u: 1; a: null, r: null; appRoleId: 1]"); + + assertEquals(user.hashCode(), user.hashCode()); + + + } + + @Test + public void testEquals(){ + + EPRole epRole = new EPRole(); + epRole.setId((long) 12345); + epRole.setName("test"); + epRole.setActive(false); + 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); + + assertTrue(user1.equals(user2)); + + } + + private EPApp mockEPApp() { + EPApp epApp = new EPApp(); + epApp.setId((long) 12345); + epApp.setName("test"); + epApp.setImageUrl("test"); + epApp.setDescription("test"); + epApp.setNotes("test"); + epApp.setUrl("test"); + epApp.setAlternateUrl("test"); + epApp.setAppRestEndpoint("test"); + epApp.setMlAppName("test"); + epApp.setMlAppAdminId("test"); + epApp.setMotsId((long)1); + epApp.setUsername("test"); + epApp.setAppPassword("test"); + return epApp; + } + } |