1 //package org.openecomp.portalapp.portal.controller;
3 //import javax.servlet.http.HttpServletRequest;
4 //import javax.servlet.http.HttpServletResponse;
6 //import org.junit.Before;
7 //import org.junit.runner.RunWith;
8 //import org.mockito.InjectMocks;
9 //import org.mockito.Mock;
10 //import org.mockito.MockitoAnnotations;
11 //import org.openecomp.portalapp.portal.core.MockEPUser;
12 //import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
13 //import org.openecomp.portalapp.portal.service.ConsulHealthService;
14 //import org.openecomp.portalapp.portal.service.ConsulHealthServiceImpl;
15 //import org.openecomp.portalapp.portal.service.MicroserviceService;
16 //import org.openecomp.portalapp.portal.service.MicroserviceServiceImpl;
17 //import org.openecomp.portalapp.portal.service.WidgetParameterService;
18 //import org.openecomp.portalapp.portal.service.WidgetParameterServiceImpl;
19 //import org.openecomp.portalapp.util.EPUserUtils;
20 //import org.powermock.core.classloader.annotations.PrepareForTest;
21 //import org.powermock.modules.junit4.PowerMockRunner;
23 //@RunWith(PowerMockRunner.class)
24 //@PrepareForTest({EPUserUtils.class})
25 //public class WidgetsCatalogControllerTest {
28 // ConsulHealthService consulHealthService = new ConsulHealthServiceImpl();
31 // MicroserviceService microserviceService = new MicroserviceServiceImpl();
34 // WidgetParameterService widgetParameterService = new WidgetParameterServiceImpl();
37 // WidgetsCatalogController widgetsCatalogController = new WidgetsCatalogController();
40 // public void setup() {
41 // MockitoAnnotations.initMocks(this);
44 // MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
46 // HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
47 // HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
49 // NullPointerException nullPointerException = new NullPointerException();
51 // MockEPUser mockUser = new MockEPUser();
53 // /*public List<WidgetCatalog> getUserWidgetCatalog(HttpServletRequest request, HttpServletResponse response,
54 // @PathVariable("loginName") String loginName) throws RestClientException, Exception {
55 // List<WidgetCatalog> widgets = new ArrayList<>();
57 // CustomLoggingFilter d;
58 // ResponseEntity<ArrayList> ans = template.exchange(
59 // EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
60 // SystemProperties.getProperty("microservices.widget.local.port"))
61 // + "/widget/microservices/widgetCatalog/" + loginName,
62 // HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), ArrayList.class);
63 // widgets = ans.getBody();
64 // } catch (Exception e) {
65 // logger.error(EELFLoggerDelegate.errorLogger, "getUserWidgetCatalog failed", e);
66 // // returning null because null help check on the UI if there was a
67 // // communication problem with Microservice.
74 // public void getWidgetDataTest(){
76 // String resourceType = null;
77 // List<WidgetCatalog> expectedData = new ArrayList<WidgetCatalog>();
78 // expectedData.setStatus(PortalRestStatusEnum.ERROR);
79 // expectedData.setMessage("Unexpected resource type null");
80 // expectedData.setResponse(null);
82 // PortalRestResponse<CommonWidgetMeta> actualResponse = dashboardController.getWidgetData(mockedRequest, resourceType);
83 // assertEquals(expectedData,actualResponse);