Add portal property; correct docker build script.
[portal.git] / ecomp-portal-BE-common-test / src / main / java / org / openecomp / portalapp / portal / test / controller / WidgetsCatalogMarkupControllerTest.java
1 package org.openecomp.portalapp.portal.test.controller;
2
3 import static org.junit.Assert.assertTrue;
4
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
7
8 import org.junit.Before;
9 import org.junit.Test;
10 import org.junit.runner.RunWith;
11 import org.mockito.InjectMocks;
12 import org.mockito.Mock;
13 import org.mockito.Mockito;
14 import org.mockito.MockitoAnnotations;
15 import org.openecomp.portalapp.portal.controller.WidgetsCatalogMarkupController;
16 import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders;
17 import org.openecomp.portalapp.portal.service.ConsulHealthService;
18 import org.openecomp.portalapp.portal.service.ConsulHealthServiceImpl;
19 import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
20 import org.openecomp.portalapp.test.framework.MockitoTestSuite;
21 import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
22 import org.openecomp.portalsdk.core.util.SystemProperties;
23 import org.powermock.api.mockito.PowerMockito;
24 import org.powermock.core.classloader.annotations.PrepareForTest;
25 import org.powermock.modules.junit4.PowerMockRunner;
26 import org.springframework.web.client.RestClientException;
27 import org.springframework.web.client.RestTemplate;
28
29 @RunWith(PowerMockRunner.class)
30 @PrepareForTest(WidgetServiceHeaders.class)
31 public class WidgetsCatalogMarkupControllerTest extends MockitoTestSuite {
32         
33         @InjectMocks
34         WidgetsCatalogMarkupController widgetsCatalogMarkupController = new WidgetsCatalogMarkupController();
35         
36         @Mock
37         ConsulHealthService consulHealthService = new ConsulHealthServiceImpl();
38         
39         @Mock
40         RestTemplate template = new RestTemplate();
41         
42         @Before
43         public void setup() {
44                 MockitoAnnotations.initMocks(this);
45         }
46     @Mock
47     CipherUtil cipherUtil= new CipherUtil();
48     
49     @Mock
50     EcompPortalUtils EcompPortalUtils =new EcompPortalUtils();
51         
52         @Mock
53         WidgetServiceHeaders WidgetServiceHeaders ;
54         
55         MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
56
57         HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
58         HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
59
60         @SuppressWarnings("static-access")
61         @Test
62         public void getWidgetMarkupTest() throws RestClientException, Exception
63         {
64                 String whatService = "widgets-service";
65                 PowerMockito.mockStatic(WidgetServiceHeaders.class);
66                 Mockito.when(template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, null) + "/widget/microservices/markup/" + 1, String.class,
67                                 WidgetServiceHeaders.getInstance())).thenReturn("Success");
68                 String response = widgetsCatalogMarkupController.getWidgetMarkup(mockedRequest, mockedResponse, 1);
69                 assertTrue(response.equals("Success")); 
70         }
71         
72 }