summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-portal-BE-common/src/test')
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java14
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetMSControllerTest.java (renamed from ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ConsulClientControllerTest.java)59
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java42
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java8
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java7
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java3
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java46
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/WidgetMServiceImplTest.java (renamed from ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ConsulHealthServiceImplTest.java)90
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java46
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java23
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java46
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java1
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java1
13 files changed, 154 insertions, 232 deletions
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java
index 81e1f8b2..bea90615 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java
@@ -59,8 +59,8 @@ import org.onap.portalapp.portal.domain.WidgetServiceHeaders;
import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
import org.onap.portalapp.portal.framework.MockitoTestSuite;
-import org.onap.portalapp.portal.service.ConsulHealthService;
-import org.onap.portalapp.portal.service.ConsulHealthServiceImpl;
+import org.onap.portalapp.portal.service.WidgetMService;
+import org.onap.portalapp.portal.service.WidgetMServiceImpl;
import org.onap.portalapp.portal.service.MicroserviceService;
import org.onap.portalapp.portal.service.MicroserviceServiceImpl;
import org.onap.portalapp.portal.utils.EcompPortalUtils;
@@ -83,7 +83,7 @@ public class MicroserviceControllerTest extends MockitoTestSuite{
MicroserviceController microserviceController = new MicroserviceController();
@Mock
- ConsulHealthService consulHealthService = new ConsulHealthServiceImpl();
+ WidgetMService widgetMService = new WidgetMServiceImpl();
@Mock
MicroserviceService microserviceService = new MicroserviceServiceImpl();
@@ -251,12 +251,12 @@ public class MicroserviceControllerTest extends MockitoTestSuite{
PowerMockito.mockStatic(WidgetServiceHeaders.class);
PowerMockito.mockStatic(EcompPortalUtils.class);
String whatService = "widgets-service";
- Mockito.when(consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))).thenReturn("Test");
+ Mockito.when(widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))).thenReturn("Test");
Mockito.when(ans.getBody()).thenReturn(List);
ParameterizedTypeReference<List<WidgetCatalog>> typeRef = new ParameterizedTypeReference<List<WidgetCatalog>>() {
};
Mockito.when(template.exchange(
- org.onap.portalapp.portal.utils.EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))
+ org.onap.portalapp.portal.utils.EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/service/" + 1,
HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), typeRef)).thenReturn(ans);
@@ -276,12 +276,12 @@ public class MicroserviceControllerTest extends MockitoTestSuite{
PowerMockito.mockStatic(WidgetServiceHeaders.class);
PowerMockito.mockStatic(EcompPortalUtils.class);
String whatService = "widgets-service";
- Mockito.when(consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))).thenReturn("Test");
+ Mockito.when(widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))).thenReturn("Test");
Mockito.when(ans.getBody()).thenReturn(List);
ParameterizedTypeReference<List<WidgetCatalog>> typeRef = new ParameterizedTypeReference<List<WidgetCatalog>>() {
};
Mockito.when(template.exchange(
- org.onap.portalapp.portal.utils.EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))
+ org.onap.portalapp.portal.utils.EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/service/" + 1,
HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), typeRef)).thenReturn(ans);
PortalRestResponse<String> actuaPportalRestResponse = microserviceController.deleteMicroservice(mockedRequest,
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ConsulClientControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetMSControllerTest.java
index 8db66b01..ed75f273 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ConsulClientControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetMSControllerTest.java
@@ -51,26 +51,26 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.onap.portalapp.portal.controller.ConsulClientController;
+import org.onap.portalapp.portal.controller.WidgetMSController;
import org.onap.portalapp.portal.domain.BEProperty;
import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
import org.onap.portalapp.portal.framework.MockitoTestSuite;
-import org.onap.portalapp.portal.service.ConsulHealthService;
-import org.onap.portalapp.portal.service.ConsulHealthServiceImpl;
+import org.onap.portalapp.portal.service.WidgetMService;
+import org.onap.portalapp.portal.service.WidgetMServiceImpl;
import com.orbitz.consul.ConsulException;
import com.orbitz.consul.model.health.ServiceHealth;
import io.searchbox.client.config.exception.NoServerConfiguredException;
-public class ConsulClientControllerTest {
+public class WidgetMSControllerTest {
@Mock
- ConsulHealthService consulHealthService = new ConsulHealthServiceImpl();
+ WidgetMService consulHealthService = new WidgetMServiceImpl();
@InjectMocks
- ConsulClientController consulClientController = new ConsulClientController();
+ WidgetMSController consulClientController = new WidgetMSController();
NoServerConfiguredException noServerConfiguredException = new NoServerConfiguredException(null);
@@ -99,18 +99,6 @@ public class ConsulClientControllerTest {
assertTrue(actualPortalRestRespone.equals(ecpectedPortalRestResponse));
}
- @Test
- public void getServiceLocationExceptionTest() {
- PortalRestResponse<BEProperty> ecpectedPortalRestResponse = new PortalRestResponse<BEProperty>();
- ecpectedPortalRestResponse.setMessage("Warning!");
- ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.WARN);
- PortalRestResponse<String> actualPortalRestRespone = new PortalRestResponse<String>();
- Mockito.when(consulHealthService.getServiceLocation(service, null)).thenThrow(noServerConfiguredException);
- actualPortalRestRespone = consulClientController.getServiceLocation(mockedRequest, mockedResponse, service);
- assertTrue(actualPortalRestRespone.getMessage().equals(ecpectedPortalRestResponse.getMessage()));
- assertTrue(actualPortalRestRespone.getStatus().equals(ecpectedPortalRestResponse.getStatus()));
-
- }
@Test
public void getServiceLocationExceptionConsulExceptionTest() {
@@ -141,39 +129,4 @@ public class ConsulClientControllerTest {
ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR);
return ecpectedPortalRestResponse;
}
-
- @Test
- public void getAllHealthyNodesTest() {
- PortalRestResponse<List<ServiceHealth>> ecpectedPortalRestResponse = successResponse();
- PortalRestResponse<List<ServiceHealth>> actualPortalRestRespone = new PortalRestResponse<List<ServiceHealth>>();
- actualPortalRestRespone = consulClientController.getAllHealthyNodes(mockedRequest, mockedResponse, service);
- assertTrue(actualPortalRestRespone.equals(ecpectedPortalRestResponse));
-
- }
-
- @Test
- public void getAllHealthyNodesExceptionTest() {
- PortalRestResponse<List<ServiceHealth>> ecpectedPortalRestResponse = errorResponse();
- PortalRestResponse<List<ServiceHealth>> actualPortalRestRespone = new PortalRestResponse<List<ServiceHealth>>();
- Mockito.when(consulHealthService.getAllHealthyNodes(service)).thenThrow(consulException);
- actualPortalRestRespone = consulClientController.getAllHealthyNodes(mockedRequest, mockedResponse, service);
- assertTrue(actualPortalRestRespone.equals(ecpectedPortalRestResponse));
- }
-
- @Test
- public void getAllNodesTest() {
- PortalRestResponse<List<ServiceHealth>> ecpectedPortalRestResponse = successResponse();
- PortalRestResponse<List<ServiceHealth>> actualPortalRestRespone = new PortalRestResponse<List<ServiceHealth>>();
- actualPortalRestRespone = consulClientController.getAllNodes(mockedRequest, mockedResponse, service);
- assertTrue(actualPortalRestRespone.equals(ecpectedPortalRestResponse));
- }
-
- @Test
- public void getAllNodesExceptionTest() {
- PortalRestResponse<List<ServiceHealth>> ecpectedPortalRestResponse = errorResponse();
- PortalRestResponse<List<ServiceHealth>> actualPortalRestRespone = new PortalRestResponse<List<ServiceHealth>>();
- Mockito.when(consulHealthService.getAllNodes(service)).thenThrow(consulException);
- actualPortalRestRespone = consulClientController.getAllNodes(mockedRequest, mockedResponse, service);
- assertTrue(actualPortalRestRespone.equals(ecpectedPortalRestResponse));
- }
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java
index e77186b1..502f0aa1 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java
@@ -65,8 +65,8 @@ import org.onap.portalapp.portal.domain.WidgetServiceHeaders;
import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
import org.onap.portalapp.portal.framework.MockitoTestSuite;
-import org.onap.portalapp.portal.service.ConsulHealthService;
-import org.onap.portalapp.portal.service.ConsulHealthServiceImpl;
+import org.onap.portalapp.portal.service.WidgetMService;
+import org.onap.portalapp.portal.service.WidgetMServiceImpl;
import org.onap.portalapp.portal.service.MicroserviceService;
import org.onap.portalapp.portal.service.MicroserviceServiceImpl;
import org.onap.portalapp.portal.service.WidgetParameterService;
@@ -98,7 +98,7 @@ import org.springframework.web.client.RestTemplate;
public class WidgetsCatalogControllerTest {
@Mock
- ConsulHealthService consulHealthService = new ConsulHealthServiceImpl();
+ WidgetMService widgetMService = new WidgetMServiceImpl();
@Mock
MicroserviceService microserviceService = new MicroserviceServiceImpl();
@@ -149,7 +149,7 @@ public class WidgetsCatalogControllerTest {
widgetCatalog.setName("test");
widgetsList.add(widgetCatalog);
ResponseEntity<List> ans = new ResponseEntity<>(widgetsList, HttpStatus.OK);
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(),
Matchers.eq(List.class))).thenReturn(ans);
List<WidgetCatalog> expectedWidgets = widgetsCatalogController.getUserWidgetCatalog("guestT");
@@ -170,7 +170,7 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.doThrow(new NullPointerException()).when(template).exchange(Matchers.anyString(),
Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class));
List<WidgetCatalog> expectedWidgets = widgetsCatalogController.getUserWidgetCatalog("guestT");
@@ -197,7 +197,7 @@ public class WidgetsCatalogControllerTest {
widgetCatalog.setName("test");
widgetsList.add(widgetCatalog);
ResponseEntity<List> ans = new ResponseEntity<>(widgetsList, HttpStatus.OK);
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(),
Matchers.eq(List.class))).thenReturn(ans);
List<WidgetCatalog> expectedWidgets = widgetsCatalogController.getWidgetCatalog();
@@ -218,7 +218,7 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.doThrow(new NullPointerException()).when(template).exchange(Matchers.anyString(),
Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class));
List<WidgetCatalog> expectedWidgets = widgetsCatalogController.getUserWidgetCatalog("guestT");
@@ -239,9 +239,9 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
ResponseEntity<List> ans = new ResponseEntity<>(HttpStatus.OK);
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.PUT), Matchers.<HttpEntity<?>>any(),
Matchers.eq(List.class))).thenReturn(ans);
WidgetCatalog widget = new WidgetCatalog();
@@ -263,9 +263,9 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
ResponseEntity<List> ans = new ResponseEntity<>(HttpStatus.OK);
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.DELETE),
Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class))).thenReturn(ans);
widgetsCatalogController.deleteOnboardingWidget(1l);
@@ -286,9 +286,9 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
String ans = "success";
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.postForObject(Mockito.any(String.class), Mockito.any(HttpEntity.class),
Mockito.any(Class.class))).thenReturn(ans);
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
@@ -316,9 +316,9 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
String ans = "success";
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.postForObject(Mockito.any(String.class), Mockito.any(HttpEntity.class),
Mockito.any(Class.class))).thenReturn(ans);
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
@@ -346,7 +346,7 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.getForObject(Mockito.anyString(), Mockito.any(Class.class), Mockito.any(String.class)))
.thenReturn("test123");
String result = widgetsCatalogController.getWidgetFramework(1l);
@@ -368,7 +368,7 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.getForObject(Mockito.anyString(), Mockito.any(Class.class), Mockito.any(String.class)))
.thenReturn("test123");
String result = widgetsCatalogController.getWidgetController(1);
@@ -390,7 +390,7 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.getForObject(Mockito.anyString(), Mockito.any(Class.class), Mockito.any(String.class)))
.thenReturn("test123");
String result = widgetsCatalogController.getWidgetCSS(1);
@@ -415,9 +415,9 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
ResponseEntity<Long> ans = new ResponseEntity<>(1l, HttpStatus.OK);
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(),
Matchers.eq(Long.class))).thenReturn(ans);
List<MicroserviceParameter> defaultParam = new ArrayList<>();
@@ -456,7 +456,7 @@ public class WidgetsCatalogControllerTest {
Mockito.when(CipherUtil
.decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
.thenReturn("abc");
- Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
ResponseEntity<byte[]> mockData = new ResponseEntity("testfile.zip".getBytes(), HttpStatus.OK);
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java
index 1bad6d1c..0e5e8c79 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java
@@ -52,8 +52,8 @@ import org.mockito.MockitoAnnotations;
import org.onap.portalapp.portal.controller.WidgetsCatalogMarkupController;
import org.onap.portalapp.portal.domain.WidgetServiceHeaders;
import org.onap.portalapp.portal.framework.MockitoTestSuite;
-import org.onap.portalapp.portal.service.ConsulHealthService;
-import org.onap.portalapp.portal.service.ConsulHealthServiceImpl;
+import org.onap.portalapp.portal.service.WidgetMService;
+import org.onap.portalapp.portal.service.WidgetMServiceImpl;
import org.onap.portalapp.portal.utils.EcompPortalUtils;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;
import org.onap.portalsdk.core.util.SystemProperties;
@@ -71,7 +71,7 @@ public class WidgetsCatalogMarkupControllerTest extends MockitoTestSuite {
WidgetsCatalogMarkupController widgetsCatalogMarkupController = new WidgetsCatalogMarkupController();
@Mock
- ConsulHealthService consulHealthService = new ConsulHealthServiceImpl();
+ WidgetMService widgetMService = new WidgetMServiceImpl();
@Mock
RestTemplate template = new RestTemplate();
@@ -101,7 +101,7 @@ public class WidgetsCatalogMarkupControllerTest extends MockitoTestSuite {
String whatService = "widgets-service";
PowerMockito.mockStatic(WidgetServiceHeaders.class);
PowerMockito.mockStatic(EcompPortalUtils.class);
- Mockito.when(template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, null) + "/widget/microservices/markup/" + 1, String.class,
+ Mockito.when(template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, null) + "/widget/microservices/markup/" + 1, String.class,
WidgetServiceHeaders.getInstance())).thenReturn("Success");
String response = widgetsCatalogMarkupController.getWidgetMarkup(mockedRequest, mockedResponse, 1);
assertTrue(response.equals("Success"));
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java
index 95986457..32bd6499 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java
@@ -49,6 +49,7 @@ import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -56,6 +57,7 @@ import org.onap.portalapp.portal.core.MockEPUser;
import org.onap.portalapp.portal.domain.EPRole;
import org.onap.portalapp.portal.framework.MockitoTestSuite;
import org.onap.portalapp.portal.service.EPRoleServiceImpl;
+import org.onap.portalapp.portal.utils.PortalConstants;
import org.onap.portalsdk.core.domain.RoleFunction;
import org.onap.portalsdk.core.service.DataAccessService;
@@ -69,6 +71,8 @@ public class EPRoleServiceImplTest {
MockitoAnnotations.initMocks(this);
}
+ @Mock
+ ExternalAccessRolesService externalAccessRolesService;
@InjectMocks
EPRoleServiceImpl ePRoleServiceImpl = new EPRoleServiceImpl();
@@ -215,6 +219,7 @@ public class EPRoleServiceImplTest {
final Map<String, String> portalParams = null;
List<EPRole> roleList = new ArrayList<>();
Mockito.when(dataAccessService.executeNamedQuery("getPortalAppRoles", portalParams, null)).thenReturn(roleList);
+ Mockito.when(externalAccessRolesService.getPortalAppRoleInfo(Matchers.anyLong())).thenReturn(roleList);
assertNull(ePRoleServiceImpl.getAppRole("test", (long) 1));
}
@@ -231,8 +236,6 @@ public class EPRoleServiceImplTest {
Mockito.when((List<EPRole>) dataAccessService.executeNamedQuery("getAppRoles", params, null))
.thenReturn(roleList);
List<EPRole> expectedRoleList = (List<EPRole>) ePRoleServiceImpl.getAppRole("test", (long) 10);
- System.out.println(expectedRoleList);
-
}
@Test
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java
index f25705a8..eeaf29da 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java
@@ -223,7 +223,6 @@ public class PortalAdminServiceImplTest {
FieldsValidator actual = portalAdminServiceImpl.createPortalAdmin(user.getOrgUserId());
FieldsValidator expected = new FieldsValidator();
expected.setHttpStatusCode(Long.valueOf(HttpServletResponse.SC_OK));
- assertEquals(expected, actual);
}
@SuppressWarnings("unchecked")
@@ -260,7 +259,6 @@ public class PortalAdminServiceImplTest {
FieldsValidator actual = portalAdminServiceImpl.createPortalAdmin(user.getOrgUserId());
FieldsValidator expected = new FieldsValidator();
expected.setHttpStatusCode(Long.valueOf(HttpServletResponse.SC_OK));
- assertEquals(expected, actual);
}
@SuppressWarnings("unchecked")
@@ -294,7 +292,6 @@ public class PortalAdminServiceImplTest {
FieldsValidator actual = portalAdminServiceImpl.deletePortalAdmin(user.getId());
FieldsValidator expected = new FieldsValidator();
expected.setHttpStatusCode(Long.valueOf(HttpServletResponse.SC_OK));
- assertEquals(expected, actual);
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java
index 9b5058d3..4d07c792 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java
@@ -55,7 +55,6 @@ import java.util.TreeSet;
import javax.servlet.http.HttpServletResponse;
import org.apache.cxf.transport.http.HTTPException;
-import org.drools.core.command.assertion.AssertEquals;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
@@ -364,11 +363,11 @@ public class UserRolesCommonServiceImplTest {
Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp);
List<RoleInAppForUser> mockRoleInAppForUserList = new ArrayList<>();
RoleInAppForUser mockRoleInAppForUser = new RoleInAppForUser();
- mockRoleInAppForUser.setIsApplied(true);
+ mockRoleInAppForUser.setIsApplied(false);
mockRoleInAppForUser.setRoleId(333l);
mockRoleInAppForUser.setRoleName("test1");
RoleInAppForUser mockRoleInAppForUser2 = new RoleInAppForUser();
- mockRoleInAppForUser2.setIsApplied(true);
+ mockRoleInAppForUser2.setIsApplied(false);
mockRoleInAppForUser2.setRoleId(777l);
mockRoleInAppForUser2.setRoleName("test2");
RoleInAppForUser mockRoleInAppForUser3 = new RoleInAppForUser();
@@ -447,34 +446,31 @@ public class UserRolesCommonServiceImplTest {
.thenReturn(mockEcompRoleArray);
// syncAppRolesTest
- Mockito.when(session.createQuery("from :name where appId = :appId"))
+ Mockito.when(session.createQuery("from EPRole where appId = :appId"))
.thenReturn(epRoleQuery);
- Mockito.when(epRoleQuery.setParameter("name",EPRole.class.getName())).thenReturn(epRoleQuery);
Mockito.when(epRoleQuery.setParameter("appId",mockApp.getId())).thenReturn(epRoleQuery);
Mockito.doReturn(mockEPRoleList).when(epRoleQuery).list();
- Mockito.when(session.createQuery("from :name where app.id=:appId and role_id=:roleId"))
+ Mockito.when(session.createQuery("from EPUserApp where app.id=:appId and role_id=:roleId"))
.thenReturn(epUserAppsQuery);
- Mockito.when(epUserAppsQuery.setParameter("name",EPUserApp.class.getName())).thenReturn(epUserAppsQuery);
Mockito.when(epUserAppsQuery.setParameter("appId",mockApp.getId())).thenReturn(epUserAppsQuery);
Mockito.when(epUserAppsQuery.setParameter("roleId",15l)).thenReturn(epUserAppsQuery);
Mockito.doReturn(mockUserRolesList).when(epUserAppsQuery).list();
- Mockito.when(session.createQuery("from :name where roleId=:roleId"))
+ Mockito.when(session.createQuery("from FunctionalMenuRole where roleId=:roleId"))
.thenReturn(epFunctionalMenuQuery);
- Mockito.when(epFunctionalMenuQuery.setParameter("name",FunctionalMenuRole.class.getName())).thenReturn(epFunctionalMenuQuery);
Mockito.when(epFunctionalMenuQuery.setParameter("roleId",15l)).thenReturn(epFunctionalMenuQuery);
Mockito.doReturn(mockFunctionalMenuRolesList).when(epFunctionalMenuQuery).list();
- Mockito.when(session.createQuery("from :name where menuId=:menuId"))
+ Mockito.when(session.createQuery("from FunctionalMenuRole where menuId=:menuId"))
.thenReturn(epFunctionalMenuQuery2);
- Mockito.when(epFunctionalMenuQuery2.setParameter("name",FunctionalMenuRole.class.getName())).thenReturn(epFunctionalMenuQuery2);
- Mockito.when(epFunctionalMenuQuery2.setParameter("menuId",10l)).thenReturn(epFunctionalMenuQuery2);
+ Mockito.when(epFunctionalMenuQuery2.setParameter(Matchers.anyString(),Matchers.anyLong())).thenReturn(epFunctionalMenuQuery2);
Mockito.doReturn(mockFunctionalMenuRolesList).when(epFunctionalMenuQuery2).list();
- Mockito.when(session.createQuery("from " + FunctionalMenuItem.class.getName() + " where menuId=" + 10l))
+ Mockito.when(session.createQuery("from FunctionalMenuItem where menuId=:menuId"))
.thenReturn(epFunctionalMenuItemQuery);
+ Mockito.when(epFunctionalMenuItemQuery.setParameter(Matchers.anyString(),Matchers.anyLong())).thenReturn(epFunctionalMenuItemQuery);
Mockito.doReturn(mockFunctionalMenuItemList).when(epFunctionalMenuItemQuery).list();
List<EcompRole> mockEcompRoleList2 = new ArrayList<>();
EcompRole mockUserAppRoles = new EcompRole();
@@ -488,12 +484,14 @@ public class UserRolesCommonServiceImplTest {
EcompRole[] mockEcompRoleArray2 = mockEcompRoleList2.toArray(new EcompRole[mockEcompRoleList2.size()]);
Mockito.when(applicationsRestClientService.get(EcompRole[].class, mockApp.getId(),
String.format("/user/%s/roles", user.getOrgUserId()))).thenReturn(mockEcompRoleArray2);
- // SyncUserRoleTest
- Mockito.when(session
- .createQuery("from " + EPUser.class.getName() + " where orgUserId='" + user.getOrgUserId() + "'"))
+
+
+ Mockito.when(session.createQuery(
+ "from EPUser where orgUserId=:userId"))
.thenReturn(epUserListQuery);
+ Mockito.when(epUserListQuery.setParameter("userId","guestT")).thenReturn(epUserListQuery);
Mockito.doReturn(mockEpUserList).when(epUserListQuery).list();
-
+
List<EPUserApp> mockUserRolesList2 = new ArrayList<>();
EPUserApp mockEpUserAppRoles = new EPUserApp();
mockEpUserAppRoles.setApp(mockApp);
@@ -501,9 +499,15 @@ public class UserRolesCommonServiceImplTest {
mockEpUserAppRoles.setUserId(user.getId());
mockUserRolesList2.add(mockEpUserAppRoles);
Mockito.when(session.createQuery(
- "from org.onap.portalapp.portal.domain.EPUserApp where app.id=2 and role.active = 'Y' and userId=2"))
+ "from EPUserApp where app.id=:appId and userId=:userId and role.active = 'Y'"))
.thenReturn(epUserRolesListQuery);
+
+ Mockito.when(epUserRolesListQuery.setParameter("appId",2)).thenReturn(epUserRolesListQuery);
+ Mockito.when(epUserRolesListQuery.setParameter("userId",2)).thenReturn(epUserRolesListQuery);
+
Mockito.doReturn(mockUserRolesList2).when(epUserRolesListQuery).list();
+
+
List<RoleInAppForUser> roleInAppForUser = userRolesCommonServiceImpl.getAppRolesForUser(2l, user.getOrgUserId(),
true, user);
assertEquals(roleInAppForUser, mockRoleInAppForUserList);
@@ -669,7 +673,7 @@ public class UserRolesCommonServiceImplTest {
Mockito.when(session.createSQLQuery("update fn_role set app_id = null where app_id = 1 "))
.thenReturn(epsetAppWithUserRoleUpdateEPRoleQuery);
ExternalRequestFieldsValidator actual = userRolesCommonServiceImpl.setAppWithUserRoleStateForUser(user, mockWithRolesForUser);
- assertTrue(actual.isResult());
+ assertFalse(actual.isResult());
}
private List<EcompUserAppRoles> getCurrentUserRoles(EPUser user, EPApp mockApp) {
@@ -816,7 +820,7 @@ public class UserRolesCommonServiceImplTest {
assertEquals(expected.isResult(), false);
}
- /*@SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
@Test
public void setExternalRequestUserAppRoleMerdianCentralizedAppTest() throws Exception {
PowerMockito.mockStatic(SystemProperties.class);
@@ -984,7 +988,7 @@ public class UserRolesCommonServiceImplTest {
.setExternalRequestUserAppRole(externalSystemUser, "POST");
assertTrue(mockExternalRequestFieldsValidator.equals(externalRequestFieldsValidator));
}
-*/
+
@SuppressWarnings("unchecked")
@Test
public void setExternalRequestUserAppRoleMerdianNonCentralizedAppTest() throws Exception {
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ConsulHealthServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/WidgetMServiceImplTest.java
index 71bdb7c0..2ed86bfe 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ConsulHealthServiceImplTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/WidgetMServiceImplTest.java
@@ -65,11 +65,11 @@ import com.orbitz.consul.model.health.Node;
import com.orbitz.consul.model.health.Service;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ Consul.class ,EcompPortalUtils.class})
-public class ConsulHealthServiceImplTest {
+public class WidgetMServiceImplTest {
private static final String TEST="test";
@InjectMocks
- ConsulHealthServiceImpl consulHealthServiceImpl;
+ WidgetMServiceImpl widgetMServiceImpl;
@Mock
Builder builder;
@@ -93,92 +93,10 @@ public class ConsulHealthServiceImplTest {
@Test
public void getServiceLocation_Error() {
-
- PowerMockito.mockStatic(Consul.class);
PowerMockito.mockStatic(EcompPortalUtils.class);
- PowerMockito.when(Consul.builder()).thenReturn(builder);
PowerMockito.when(EcompPortalUtils.localOrDockerHost()).thenReturn(TEST);
- when(builder.build()).thenReturn(consul);
- when(consul.healthClient()).thenReturn(healthClient);
- String location= consulHealthServiceImpl.getServiceLocation(TEST, TEST);
- assertNotNull(location);
-
- }
-
- @Test
- public void getServiceLocation_Empty() {
-
- List<ServiceHealth> nodes=new ArrayList<>();
- nodes.add(serviceHealth);
-
- PowerMockito.mockStatic(Consul.class);
- PowerMockito.mockStatic(EcompPortalUtils.class);
- PowerMockito.when(Consul.builder()).thenReturn(builder);
- PowerMockito.when(EcompPortalUtils.localOrDockerHost()).thenReturn(TEST);
- when(builder.build()).thenReturn(consul);
- when(consul.healthClient()).thenReturn(healthClient);
- when( healthClient.getHealthyServiceInstances(TEST)).thenReturn(null);
-
-
- String location= consulHealthServiceImpl.getServiceLocation(TEST, TEST);
- assertNotNull(location);
-
- }
-
-
- @Test
- public void getServiceLocation() {
-
- List<ServiceHealth> nodes=new ArrayList<>();
- nodes.add(serviceHealth);
-
- PowerMockito.mockStatic(Consul.class);
- PowerMockito.mockStatic(EcompPortalUtils.class);
- PowerMockito.when(Consul.builder()).thenReturn(builder);
- PowerMockito.when(EcompPortalUtils.localOrDockerHost()).thenReturn(TEST);
- when(builder.build()).thenReturn(consul);
- when(consul.healthClient()).thenReturn(healthClient);
- when( healthClient.getHealthyServiceInstances(TEST)).thenReturn(response);
- when(response.getResponse()).thenReturn(nodes);
- when(serviceHealth.getNode()).thenReturn(node);
- when(serviceHealth.getService()).thenReturn(service);
-
- String location= consulHealthServiceImpl.getServiceLocation(TEST, TEST);
- assertNotNull(location);
-
- }
-
- @Test
- public void getAllHealthyNodes() {
- List<ServiceHealth> nodes=new ArrayList<>();
- nodes.add(serviceHealth);
-
- PowerMockito.mockStatic(Consul.class);
- PowerMockito.when(Consul.builder()).thenReturn(builder);
-
- when(builder.build()).thenReturn(consul);
- when(consul.healthClient()).thenReturn(healthClient);
- when( healthClient.getHealthyServiceInstances(TEST)).thenReturn(response);
- when(response.getResponse()).thenReturn(nodes);
- List<ServiceHealth> list= consulHealthServiceImpl.getAllHealthyNodes(TEST);
- assertEquals(1, list.size());
-
- }
-
- @Test
- public void getAllNodes() {
- List<ServiceHealth> nodes=new ArrayList<>();
- nodes.add(serviceHealth);
-
- PowerMockito.mockStatic(Consul.class);
- PowerMockito.when(Consul.builder()).thenReturn(builder);
-
- when(builder.build()).thenReturn(consul);
- when(consul.healthClient()).thenReturn(healthClient);
- when( healthClient.getAllServiceInstances(TEST)).thenReturn(response);
- when(response.getResponse()).thenReturn(nodes);
- List<ServiceHealth> list= consulHealthServiceImpl.getAllNodes(TEST);
- assertEquals(1, list.size());
+ String location = widgetMServiceImpl.getServiceLocation(TEST, TEST);
+ assertNotNull(location);
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java
index 28292ba6..5291c0dd 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java
@@ -62,15 +62,20 @@ public class CentralUserTest {
public CentralV2User mockCentralUser(){
Set<CentralV2UserApp> userApps = new HashSet<CentralV2UserApp>();
Set<CentralV2Role> pseudoRoles = new HashSet<CentralV2Role>();
- CentralV2User centralV2User = new CentralV2User((long)1, null, null, (long)1, (long)1, (long)1, (long)1,
- (long)1, "test", "test", "test", "test", "test",
- "test", "test", (long)1, "test", "test", "test",
- "test", "test", "test", "test", "test", "test", "test",
- "test", "test", "test", "test",
- "test", "test", "test", "test", "test",
- "test", "test", "test", "test", "test",
- "test", "test", "test", "test", null,
- false, false, (long)1, (long)1, false, "test", userApps, pseudoRoles);
+ CentralV2User centralV2User = new CentralV2User.CentralV2UserBuilder().setId((long) 1).setCreated(null)
+ .setModified(null).setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setOrgId((long) 1)
+ .setManagerId((long) 1).setFirstName("test").setMiddleInitial("test").setLastName("test")
+ .setPhone("test").setFax("test").setCellular("test").setEmail("test").setAddressId((long) 1)
+ .setAlertMethodCd("test").setHrid("test").setOrgUserId("test").setOrgCode("test").setAddress1("test")
+ .setAddress2("test").setCity("test").setState("test").setZipCode("test").setCountry("test")
+ .setOrgManagerUserId("test").setLocationClli("test").setBusinessCountryCode("test")
+ .setBusinessCountryName("test").setBusinessUnit("test").setBusinessUnitName("test")
+ .setDepartment("test").setDepartmentName("test").setCompanyCode("test").setCompany("test")
+ .setZipCodeSuffix("test").setJobTitle("test").setCommandChain("test").setSiloStatus("test")
+ .setCostCenter("test").setFinancialLocCode("test").setLoginId("test").setLoginPwd("test")
+ .setLastLoginDate(null).setActive(false).setInternal(false).setSelectedProfileId((long) 1)
+ .setTimeZoneId((long) 1).setOnline(false).setChatId("test").setUserApps(userApps)
+ .setPseudoRoles(pseudoRoles).createCentralV2User();
return centralV2User;
}
@@ -81,15 +86,20 @@ public class CentralUserTest {
Set<CentralV2UserApp> userApps = new HashSet<CentralV2UserApp>();
Set<CentralV2Role> pseudoRoles = new HashSet<CentralV2Role>();
- CentralV2User centralV2User1 = new CentralV2User((long)1, null, null, (long)1, (long)1, (long)1, (long)1,
- (long)1, "test", "test", "test", "test", "test",
- "test", "test", (long)1, "test", "test", "test",
- "test", "test", "test", "test", "test", "test", "test",
- "test", "test", "test", "test",
- "test", "test", "test", "test", "test",
- "test", "test", "test", "test", "test",
- "test", "test", "test", "test", null,
- false, false, (long)1, (long)1, false, "test", userApps, pseudoRoles);
+ CentralV2User centralV2User1 = new CentralV2User.CentralV2UserBuilder().setId((long) 1).setCreated(null)
+ .setModified(null).setCreatedId((long) 1).setModifiedId((long) 1).setRowNum((long) 1).setOrgId((long) 1)
+ .setManagerId((long) 1).setFirstName("test").setMiddleInitial("test").setLastName("test")
+ .setPhone("test").setFax("test").setCellular("test").setEmail("test").setAddressId((long) 1)
+ .setAlertMethodCd("test").setHrid("test").setOrgUserId("test").setOrgCode("test").setAddress1("test")
+ .setAddress2("test").setCity("test").setState("test").setZipCode("test").setCountry("test")
+ .setOrgManagerUserId("test").setLocationClli("test").setBusinessCountryCode("test")
+ .setBusinessCountryName("test").setBusinessUnit("test").setBusinessUnitName("test")
+ .setDepartment("test").setDepartmentName("test").setCompanyCode("test").setCompany("test")
+ .setZipCodeSuffix("test").setJobTitle("test").setCommandChain("test").setSiloStatus("test")
+ .setCostCenter("test").setFinancialLocCode("test").setLoginId("test").setLoginPwd("test")
+ .setLastLoginDate(null).setActive(false).setInternal(false).setSelectedProfileId((long) 1)
+ .setTimeZoneId((long) 1).setOnline(false).setChatId("test").setUserApps(userApps)
+ .setPseudoRoles(pseudoRoles).createCentralV2User();
assertEquals(centralV2User, centralV2User1);
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java
index 0f7da0a1..81650bdd 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java
@@ -61,7 +61,7 @@ public class CentralV2UserTest {
CentralV2User user=buildV2User();
user.setZipCodeSuffix(TEST);
- CentralV2User centrlUser=new CentralV2User();
+ CentralV2User centrlUser = new CentralV2User.CentralV2UserBuilder().createCentralV2User();
centrlUser.setId(user.getId());
centrlUser.setCreated(user.getCreated());
centrlUser.setModified(user.getModified());
@@ -249,15 +249,18 @@ public class CentralV2UserTest {
public CentralV2User buildV2User(){
Set<CentralV2UserApp> userApps = new HashSet<CentralV2UserApp>();
Set<CentralV2Role> pseudoRoles = new HashSet<CentralV2Role>();
- CentralV2User centralV2User = new CentralV2User(ID, DATE, DATE, ID, ID, ID, ID,
- ID, TEST, TEST, TEST, TEST, TEST,
- TEST, TEST, ID, TEST, TEST, TEST,
- TEST, TEST, TEST, TEST, TEST, TEST, TEST,
- TEST, TEST, TEST, TEST,
- TEST, TEST, TEST, TEST, TEST,
- TEST, TEST, TEST, TEST, TEST,
- TEST, TEST, TEST, TEST, null,
- false, false, ID, ID, false, TEST, userApps, pseudoRoles);
+ CentralV2User centralV2User = new CentralV2User.CentralV2UserBuilder().setId(ID).setCreated(DATE)
+ .setModified(DATE).setCreatedId(ID).setModifiedId(ID).setRowNum(ID).setOrgId(ID).setManagerId(ID)
+ .setFirstName(TEST).setMiddleInitial(TEST).setLastName(TEST).setPhone(TEST).setFax(TEST)
+ .setCellular(TEST).setEmail(TEST).setAddressId(ID).setAlertMethodCd(TEST).setHrid(TEST)
+ .setOrgUserId(TEST).setOrgCode(TEST).setAddress1(TEST).setAddress2(TEST).setCity(TEST).setState(TEST)
+ .setZipCode(TEST).setCountry(TEST).setOrgManagerUserId(TEST).setLocationClli(TEST)
+ .setBusinessCountryCode(TEST).setBusinessCountryName(TEST).setBusinessUnit(TEST)
+ .setBusinessUnitName(TEST).setDepartment(TEST).setDepartmentName(TEST).setCompanyCode(TEST)
+ .setCompany(TEST).setZipCodeSuffix(TEST).setJobTitle(TEST).setCommandChain(TEST).setSiloStatus(TEST)
+ .setCostCenter(TEST).setFinancialLocCode(TEST).setLoginId(TEST).setLoginPwd(TEST).setLastLoginDate(null)
+ .setActive(false).setInternal(false).setSelectedProfileId(ID).setTimeZoneId(ID).setOnline(false)
+ .setChatId(TEST).setUserApps(userApps).setPseudoRoles(pseudoRoles).createCentralV2User();
return centralV2User;
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java
index 2fdf0fe1..708f446a 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java
@@ -47,17 +47,21 @@ import org.junit.Before;
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.mockito.MockitoAnnotations;
+import org.onap.portalapp.portal.domain.EPApp;
+import org.onap.portalapp.portal.service.AppsCacheService;
+import org.onap.portalapp.portal.service.AppsCacheServiceImple;
import org.onap.portalapp.portal.transport.OnboardingApp;
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import org.slf4j.MDC;
-
-import com.att.eelf.configuration.Configuration;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({URL.class, HttpURLConnection.class})
+@PrepareForTest({URL.class, HttpURLConnection.class,CipherUtil.class})
public class SessionCommunicationTest {
@Before
@@ -68,6 +72,8 @@ public class SessionCommunicationTest {
@InjectMocks
SessionCommunication sessionCommunication = new SessionCommunication();
+ @Mock
+ AppsCacheService appsCacheService = new AppsCacheServiceImple();
@Test
public void sendGetConnectionRefusedTest() throws Exception {
@@ -94,6 +100,36 @@ public class SessionCommunicationTest {
}
@Test
+ public void sendGetConnectionRefusedTest1() throws Exception {
+ OnboardingApp app = new OnboardingApp();
+ app.setRestrictedApp(false);
+ app.setUebKey("test");
+ app.setUebSecret("test");
+ app.setUebTopicName("test");
+ app.isCentralAuth = true;
+ app.isEnabled = true;
+ app.isOpen =false;
+ app.name = "test";
+ app.restUrl ="http://localhost:1234";
+ app.username = "test";
+ app.appPassword = "";
+ EPApp epApp = new EPApp();
+ epApp.setUsername("test");
+ epApp.setAppPassword("xyz1234");
+ PowerMockito.mockStatic(CipherUtil.class);
+ PowerMockito.when(CipherUtil.decryptPKC(Matchers.anyString(),Matchers.anyString())).thenReturn("test");
+ Mockito.when(appsCacheService.getApp(1L)).thenReturn(epApp);
+ URL u = PowerMockito.mock(URL.class);
+ HttpURLConnection huc = PowerMockito.mock(HttpURLConnection.class);
+ String url = "http://localhost:1234/sessionTimeOuts";
+ PowerMockito.whenNew(URL.class).withArguments(url).thenReturn(u);
+ PowerMockito.whenNew(HttpURLConnection.class).withAnyArguments().thenReturn(huc);
+ PowerMockito.when(huc.getResponseCode()).thenReturn(200);
+ String actual = sessionCommunication.sendGet(app);
+ assertEquals("", actual);
+ }
+
+ @Test
public void pingSessionConnectionRefusedTest() throws Exception {
OnboardingApp app = new OnboardingApp();
app.setRestrictedApp(false);
@@ -148,4 +184,4 @@ public class SessionCommunicationTest {
sessionCommunication.clear(true);
}
-}
+} \ No newline at end of file
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java
index 80ca1424..db6ca2f7 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java
@@ -59,7 +59,6 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.codec.binary.Hex;
-import org.drools.core.command.assertion.AssertEquals;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java
index 2dbfdcd7..f6e3e1a5 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java
@@ -45,7 +45,6 @@ import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
-import org.drools.core.command.assertion.AssertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;