summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorTal Gitelman <tal.gitelman@att.com>2018-11-29 11:57:23 +0200
committerMichael Lando <michael.lando@intl.att.com>2018-11-29 11:38:10 +0000
commitd8bdab062d106a854ae7719433baeaa3954c88b6 (patch)
tree7efefafebad94ff9324e3dddea84f08145076214 /catalog-be/src/test/java
parentd7b6bb274a1cc6f4e303045587b7c61e505e0fb7 (diff)
update sdc portal integration
Issue-ID: SDC-1749 Change-Id: Ie306076357cb572402ac80b4be9eb9c5cfa960dd Signed-off-by: Tal Gitelman <tal.gitelman@att.com>
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImplTest.java151
2 files changed, 152 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
index 6ba28fe103..20f7f1874a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
@@ -48,6 +48,7 @@ import java.util.Map;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
+
public abstract class BaseServiceBusinessLogicTest {
private static final String SERVICE_CATEGORY = "Mobility";
final ServletContext servletContext = Mockito.mock(ServletContext.class);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImplTest.java
new file mode 100644
index 0000000000..552d2dd4a6
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImplTest.java
@@ -0,0 +1,151 @@
+package org.openecomp.sdc.be.ecomp;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.springframework.web.context.ContextLoader;
+import org.springframework.web.context.WebApplicationContext;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class PortalRestAPICentralServiceImplTest {
+ @Mock
+ ContextLoader conLoader;
+ @Mock
+ WebApplicationContext apContext;
+ @Mock
+ UserBusinessLogic userBusinessLogic;
+ @Mock
+ ContextLoader ctx;
+ @InjectMocks
+ PortalRestAPICentralServiceImpl testSubject;
+
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testGetAppCredentials() throws Exception {
+ Map<String, String> appCredentials = testSubject.getAppCredentials();
+ Assert.assertTrue(appCredentials.get(PortalRestAPICentralServiceImpl.PortalPropertiesEnum.PORTAL_APP_NAME.value()).equals("sdc"));
+ Assert.assertTrue(appCredentials.get(PortalRestAPICentralServiceImpl.PortalPropertiesEnum.PORTAL_USER.value()).equals("sdc"));
+ Assert.assertTrue(appCredentials.get(PortalRestAPICentralServiceImpl.PortalPropertiesEnum.PORTAL_PASS.value()).equals("asdc"));
+ }
+
+ /*@Test
+ public void testPushUser() throws Exception {
+ EcompUser user = new EcompUser();
+ Set<EcompRole> roleSet = new HashSet<>();
+ EcompRole role = new EcompRole();
+ role.setId(1L);
+ role.setName("Designer");
+ roleSet.add(role);
+ user.setRoles(roleSet);
+ testSubject.pushUser(user);
+ }*/
+
+ @Test
+ public void testPushUserNullRoles() throws Exception {
+ EcompUser user = new EcompUser();
+ try{
+ testSubject.pushUser(user);
+ } catch (PortalAPIException e){
+ Assert.assertTrue(e.getMessage().equals("Received null roles for user" + user));
+ }
+
+ }
+
+ @Test
+ public void testPushUserUserNull() throws Exception {
+ try {
+ testSubject.pushUser(null);
+ } catch (PortalAPIException e) {
+ Assert.assertTrue(e.getMessage().equals("Received null for argument user"));
+ }
+
+ }
+
+ /**
+ *
+ * Method: editUser(String loginId, EcompUser user)
+ *
+ */
+ @Test
+ public void testEditUser() throws Exception {
+ //TODO: Test goes here...
+ }
+
+ /**
+ *
+ * Method: getUserId(HttpServletRequest request)
+ *
+ */
+ @Test
+ public void testGetUserId() throws Exception {
+ //TODO: Test goes here...
+ }
+
+ /**
+ *
+ * Method: value()
+ *
+ */
+ @Test
+ public void testValue() throws Exception {
+ //TODO: Test goes here...
+ }
+
+
+ /**
+ *
+ * Method: getUserBusinessLogic()
+ *
+ */
+ @Test
+ public void testGetUserBusinessLogic() throws Exception {
+ //TODO: Test goes here...
+
+ try {
+ Method method = testSubject.getClass().getMethod("getUserBusinessLogic");
+ method.setAccessible(true);
+ method.invoke(testSubject);
+ } catch(NoSuchMethodException e) {
+ } catch(IllegalAccessException e) {
+ } catch(InvocationTargetException e) {
+ }
+ }
+
+ /**
+ *
+ * Method: checkIfSingleRoleProvided(EcompUser user)
+ *
+ */
+ @Test
+ public void testCheckIfSingleRoleProvided() throws Exception {
+ //TODO: Test goes here...
+ /*
+ try {
+ Method method = PortalRestAPICentralServiceImpl.getClass().getMethod("checkIfSingleRoleProvided", EcompUser.class);
+ method.setAccessible(true);
+ method.invoke(<Object>, <Parameters>);
+ } catch(NoSuchMethodException e) {
+ } catch(IllegalAccessException e) {
+ } catch(InvocationTargetException e) {
+ }
+ */
+ }
+
+}