summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-domain/src
diff options
context:
space:
mode:
authorKishore Reddy, Gujja (kg811t) <kg811t@research.att.com>2018-08-15 08:39:30 -0400
committerKishore Reddy, Gujja (kg811t) <kg811t@research.att.com>2018-08-15 11:21:38 -0400
commitecfe375994b7561d37a07f8879740b1c85f260a2 (patch)
tree2876499d2adeecea4af8641662722a3a3627338d /ecomp-sdk/epsdk-domain/src
parent2e2ec498ce80d674c08ef8909adb5e1138b710bd (diff)
Modified User Auth and permission aaf services
Issue-ID: PORTAL-334 Change-Id: I461fd5a61879434e9c105c7598e9948004a5f608 Signed-off-by: Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-domain/src')
-rw-r--r--ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java25
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java4
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java20
3 files changed, 25 insertions, 24 deletions
diff --git a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java
index 4eebb02f..aff5b1f1 100644
--- a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java
+++ b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -91,33 +91,26 @@ public class UserApp implements java.io.Serializable, Comparable {
return (this.getUserId().equals(castOther.getUserId()))
&& (this.getApp().getId().equals(castOther.getApp().getId()))
- && (this.getRole().getId().equals(castOther.getRole().getId()))
+ && (this.getRole().getId() != null ? this.getRole().getId().equals(castOther.getRole().getId()) : this.getRole().getName().equals(castOther.getRole().getName()))
&& ((this.priority == null && castOther.getPriority() == null)
|| this.getPriority().equals(castOther.getPriority()));
}
@Override
public int hashCode() {
- int result = 17;
- result = 37 * result + (int) (this.getUserId() == null ? 0 : this.getUserId().intValue());
- result = 37 * result + (int) (this.getApp().getId() == null ? 0 : this.getApp().getId().intValue());
- result = 37 * result + (int) (this.getRole().getId() == null ? 0 : this.getRole().getId().intValue());
+ Long result = 17l;
+ result = 37 * result + (int) (this.getUserId() == null ? 0 : this.getUserId().hashCode());
+ result = 37 * result + (int) (this.getApp().getId() == null ? 0 : this.getApp().getId().hashCode());
+ result = 37 * result + (int) (this.getRole().getId() == null ? (this.getRole().getName() == null ? 0 : this.getRole().getName().hashCode() ) : this.getRole().getId().hashCode());
result = 37 * result + (int) (this.priority == null ? 0 : this.priority);
- return result;
+ return Long.hashCode(result);
}
@Override
public int compareTo(Object other) {
UserApp castOther = (UserApp) other;
- Long c1 = (this.getUserId() == null ? 0 : this.getUserId())
- + (this.getApp() == null || this.getApp().getId() == null ? 0 : this.getApp().getId())
- + (this.getRole() == null || this.getRole().getId() == null ? 0 : this.getRole().getId())
- + (this.priority == null ? 0 : this.priority);
- Long c2 = (castOther.getUserId() == null ? 0 : castOther.getUserId())
- + (castOther.getApp() == null || castOther.getApp().getId() == null ? 0 : castOther.getApp().getId())
- + (castOther.getRole() == null || castOther.getRole().getId() == null ? 0 : castOther.getRole().getId())
- + (castOther.priority == null ? 0 : castOther.priority);
- return c1.compareTo(c2);
+ int c1 = this.hashCode() - castOther.hashCode();
+ return c1;
}
}
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java
index 2433d93b..288b5a21 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -66,7 +66,7 @@ public class UserAppTest {
UserApp userapp2 = mockUserApp();
userapp2.setUserId((long) 2);
assertNull(userapp1.getPriority());
- assertEquals(userapp2.compareTo(userapp1), 1);
+ assertEquals(userapp2.compareTo(userapp1), 50653);
assertNotNull(userapp1.hashCode());
userapp2.setUserId((long) 1);
assertTrue(userapp1.equals(userapp2));
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java
index 598ee900..b4fb2ced 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -37,17 +37,15 @@
*/
package org.onap.portalsdk.core.domain;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.junit.Test;
-import org.onap.portalsdk.core.domain.App;
-import org.onap.portalsdk.core.domain.Role;
-import org.onap.portalsdk.core.domain.User;
-import org.onap.portalsdk.core.domain.UserApp;
public class UserTest {
@@ -165,8 +163,14 @@ public class UserTest {
public void addAppRolesIfRolesNullTest()
{
User user = mockUser();
+ App appTest = new App();
+ appTest.setId(1l);
+ SortedSet<Role> roles = new TreeSet<>();
Set userApps = new TreeSet();
UserApp userapp = new UserApp();
+ userapp.setApp(appTest);
+ userapp.setRole(new Role());
+ user.setRoles(roles);
userApps.add(userapp);
user.setUserApps(userApps);
user.setUserApps(userApps);
@@ -195,11 +199,15 @@ public class UserTest {
User user = mockUser();
Set userApps = new TreeSet();
UserApp userapp = new UserApp();
+ App app = new App();
+ app.setId(1l);
SortedSet<Role> roles = new TreeSet();
Role role = new Role();
role.setId((long) 1);
+ role.setName("test");
roles.add(role);
userapp.setRole(role);
+ userapp.setApp(app);
userApps.add(userapp);
user.setUserApps(userApps);
user.removeRole((long) 1);