import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.onap.portalapp.portal.controller.WidgetsCatalogController;
import org.onap.portalapp.portal.core.MockEPUser;
import org.onap.portalapp.portal.domain.EPUser;
import org.onap.portalapp.portal.domain.MicroserviceParameter;
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.MicroserviceService;
import org.onap.portalapp.portal.service.MicroserviceServiceImpl;
+import org.onap.portalapp.portal.service.WidgetMService;
+import org.onap.portalapp.portal.service.WidgetMServiceImpl;
import org.onap.portalapp.portal.service.WidgetParameterService;
import org.onap.portalapp.portal.service.WidgetParameterServiceImpl;
import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
import org.onap.portalapp.portal.utils.EcompPortalUtils;
import org.onap.portalapp.util.EPUserUtils;
-import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;
import org.onap.portalsdk.core.util.SystemProperties;
import org.powermock.api.mockito.PowerMockito;
public class WidgetsCatalogControllerTest {
@Mock
- ConsulHealthService consulHealthService = new ConsulHealthServiceImpl();
+ WidgetMService widgetMService = new WidgetMServiceImpl();
@Mock
MicroserviceService microserviceService = new MicroserviceServiceImpl();
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");
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");
}
@Test
- public void getWidgetCatalogTest() throws CipherUtilException {
+ public void getWidgetCatalogTest() throws Exception {
PowerMockito.mockStatic(EcompPortalUtils.class);
PowerMockito.mockStatic(SystemProperties.class);
PowerMockito.mockStatic(EPCommonSystemProperties.class);
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();
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");
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();
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);
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();
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();
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);
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);
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);
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<>();
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);