diff options
author | 2018-03-06 09:44:53 -0500 | |
---|---|---|
committer | 2018-03-06 17:43:16 -0500 | |
commit | cfb69f44f841338e1f208225ec006388e986bd2c (patch) | |
tree | e8b7e982637a5b27f3383a793fcdcee50f7e0057 /ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core | |
parent | 724ff8f8b22d6503ce5070ebc13f6f5fbc48c8cf (diff) |
Added Junits & AAF attributes Support
Issue-ID: PORTAL-136
Includes JUNITS, AAF attributes support
Change-Id: Id4cc9f64268017665d7245d0a10369c9b498ba2f
Signed-off-by: Kotta, Shireesha (sk434m) <sk434m@att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core')
2 files changed, 13 insertions, 10 deletions
diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java index 0b61af8d..338b31c8 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java @@ -44,6 +44,7 @@ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.onap.portalsdk.core.domain.Role; @@ -63,7 +64,7 @@ public class RoleServiceCentralizedAccessTest { public void getRoleFunctionsTest() throws Exception { String loginId ="1234"; String response ="[ { \"code\" : \"abc\", \"name\" : \"xyz\" }, { \"code\" : \"pqr\", \"name\" : \"str\" } ]"; - Mockito.when(restApiRequestBuilder.getViaREST("/functions", true, loginId)).thenReturn(response); + Mockito.when(restApiRequestBuilder.getViaREST(Matchers.anyString(), Matchers.anyBoolean(), Matchers.anyString())).thenReturn(response); List<RoleFunction> roleFunctions = roleServiceCntrlAccess.getRoleFunctions(loginId); Assert.assertTrue(roleFunctions.size() > 0); } @@ -73,7 +74,7 @@ public class RoleServiceCentralizedAccessTest { String loginId = "123"; Long roleId = null; String response ="[ { \"active\" : true, \"name\" : \"xyz\" } ]"; - Mockito.when(restApiRequestBuilder.getViaREST("/roles", true, loginId)).thenReturn(response); + Mockito.when(restApiRequestBuilder.getViaREST("/v1/roles", true, loginId)).thenReturn(response); List<Role> roles = roleServiceCntrlAccess.getAvailableChildRoles(loginId, roleId); Assert.assertNotNull(roles); } @@ -83,7 +84,7 @@ public class RoleServiceCentralizedAccessTest { String loginId = "123"; Long roleId = 0L; String response ="[ { \"active\" : true, \"name\" : \"xyz\" } ]"; - Mockito.when(restApiRequestBuilder.getViaREST("/roles", true, loginId)).thenReturn(response); + Mockito.when(restApiRequestBuilder.getViaREST("/v1/roles", true, loginId)).thenReturn(response); List<Role> roles = roleServiceCntrlAccess.getAvailableChildRoles(loginId, roleId); Assert.assertNotNull(roles); } @@ -93,9 +94,9 @@ public class RoleServiceCentralizedAccessTest { String loginId = "123"; Long roleId = 123L; String response ="[ { \"active\" : false, \"name\" : \"xyz\" } ]"; - Mockito.when(restApiRequestBuilder.getViaREST("/roles", true, loginId)).thenReturn(response); - String roleResponse =" { \"active\" : true, \"name\" : \"xyz\", \"roleFunctions\" : [ { \"code\" : \"abc\", \"name\" : \"RF1\" }, { \"code\" : \"pqr\", \"name\" : \"RF2\" } ] , \"parentRoles\": [ {\"active\" : false, \"name\" : \"XYZ-ABC\"}, {\"active\" : true, \"name\" : \"ABC\"} ] } "; - Mockito.when(restApiRequestBuilder.getViaREST("/role/" + roleId, true, loginId)).thenReturn(roleResponse); + Mockito.when(restApiRequestBuilder.getViaREST("/v1/roles", true, loginId)).thenReturn(response); + String roleResponse =" { \"active\" : true, \"name\" : \"xyz\", \"roleFunctions\" : [ { \"code\" : \"abc\", \"name\" : \"RF1\" , \"type\" : \"abc\", \"action\" : \"abc\" }, { \"code\" : \"pqr\", \"name\" : \"RF2\" , \"type\" : \"abc\", \"action\" : \"abc\" } ] , \"parentRoles\": [ {\"active\" : false, \"name\" : \"XYZ-ABC\"}, {\"active\" : true, \"name\" : \"ABC\"} ] } "; + Mockito.when(restApiRequestBuilder.getViaREST("/v1/role/" + roleId, true, loginId)).thenReturn(roleResponse); roleServiceCntrlAccess.getAvailableChildRoles(loginId, roleId); Assert.assertTrue(true); } @@ -121,7 +122,7 @@ public class RoleServiceCentralizedAccessTest { public void getActiveRolesTest() throws Exception { String requestedLoginId ="1234"; String response ="[ { \"active\" : true, \"name\" : \"role1\" }, { \"active\" : false, \"name\" : \"role2\" } ]"; - Mockito.when(restApiRequestBuilder.getViaREST("/activeRoles", true, requestedLoginId)).thenReturn(response); + Mockito.when(restApiRequestBuilder.getViaREST("/v1/activeRoles", true, requestedLoginId)).thenReturn(response); List<Role> roles = roleServiceCntrlAccess.getActiveRoles(requestedLoginId); Assert.assertNotNull(roles); } @@ -131,8 +132,9 @@ public class RoleServiceCentralizedAccessTest { String requestedLoginId = "xyz"; String code ="abc"; - String responseString = " { \"code\" : \"abc\", \"name\" : \"xyz\" }"; - Mockito.when(restApiRequestBuilder.getViaREST("/function/" + code, true, requestedLoginId)).thenReturn(responseString); + String responseString = " { \"code\" : \"abc\", \"name\" : \"xyz\" , \"type\" : \"abc\", \"action\" : \"abc\" }"; +// Mockito.when(restApiRequestBuilder.getViaREST("v1/function/" + code, true, requestedLoginId)).thenReturn(responseString); + Mockito.when(restApiRequestBuilder.getViaREST(Matchers.anyString(), Matchers.anyBoolean(), Matchers.anyString())).thenReturn(responseString); RoleFunction roleFunction = roleServiceCntrlAccess.getRoleFunction(requestedLoginId, code); Assert.assertNotNull(roleFunction); } diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/UserServiceCentalizedImplTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/UserServiceCentalizedImplTest.java index 82b4a6e0..17fadcc6 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/UserServiceCentalizedImplTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/UserServiceCentalizedImplTest.java @@ -43,6 +43,7 @@ import java.util.List; import java.util.Map; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -75,7 +76,7 @@ public class UserServiceCentalizedImplTest { params.put("user_id", new Long(id)); Mockito.when(dataAccessService.executeNamedQuery("getUserByProfileId", params, null)).thenReturn(orgUsreIds); String responseString = " { \"id\": 2, \"userApps\":[{\"app\":{\"id\":1},\"role\":{\"active\":true, \"roleFunctions\":[{\"id\":1}] } } ] }"; - Mockito.when(restApiRequestBuilder.getViaREST("/user/" + orgUserId, true, id)).thenReturn(responseString); + Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + orgUserId, true, id)).thenReturn(responseString); User user = userServiceCentalizedImpl.getUser(id); Assert.assertNotNull(user); |