diff options
author | Dominik Mizyn <d.mizyn@samsung.com> | 2019-10-01 14:52:49 +0200 |
---|---|---|
committer | Dominik Mizyn <d.mizyn@samsung.com> | 2019-10-03 10:26:15 +0200 |
commit | e90cfa3b65b9879d22fc4522f45a22f1014e224e (patch) | |
tree | eccba7283aa9c05a34120569829348ab69113a74 /portal-BE/src/test | |
parent | f2805494b772201a94334e2c2f72315cacd8266b (diff) |
WidgetsCatalogControllerTest up
WidgetsCatalogControllerTest up
Issue-ID: PORTAL-710
Change-Id: I09c2ee9ab72108b2f62939a3a5ac2441376774e2
Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
Diffstat (limited to 'portal-BE/src/test')
-rw-r--r-- | portal-BE/src/test/java/org/onap/portal/controller/WidgetMSControllerTest.java | 41 | ||||
-rw-r--r-- | portal-BE/src/test/java/org/onap/portal/controller/WidgetsCatalogControllerTest.java | 147 |
2 files changed, 188 insertions, 0 deletions
diff --git a/portal-BE/src/test/java/org/onap/portal/controller/WidgetMSControllerTest.java b/portal-BE/src/test/java/org/onap/portal/controller/WidgetMSControllerTest.java new file mode 100644 index 00000000..2f9f4235 --- /dev/null +++ b/portal-BE/src/test/java/org/onap/portal/controller/WidgetMSControllerTest.java @@ -0,0 +1,41 @@ +package org.onap.portal.controller; + +import static org.junit.jupiter.api.Assertions.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.onap.portal.domain.dto.ecomp.PortalRestResponse; +import org.onap.portal.domain.dto.ecomp.PortalRestStatusEnum; +import org.onap.portal.framework.MockitoTestSuite; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +@TestPropertySource(locations = "classpath:test.properties") +class WidgetMSControllerTest { + + @Autowired + WidgetMSController widgetMSController; + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest request = mockitoTestSuite.getMockedRequest(); + HttpServletResponse response = mockitoTestSuite.getMockedResponse(); + + @Test + void getServiceLocation() { + PortalRestResponse<String> expected = new PortalRestResponse<>(); + expected.setMessage("Error!"); + expected.setResponse("Couldn't get the service location"); + expected.setStatus(PortalRestStatusEnum.ERROR); + PortalRestResponse<String> actual = widgetMSController.getServiceLocation(request, response, "portal"); + assertEquals(expected.getMessage(), actual.getMessage()); + assertEquals(expected.getResponse(), actual.getResponse()); + assertEquals(expected.getStatus(), actual.getStatus()); + } +}
\ No newline at end of file diff --git a/portal-BE/src/test/java/org/onap/portal/controller/WidgetsCatalogControllerTest.java b/portal-BE/src/test/java/org/onap/portal/controller/WidgetsCatalogControllerTest.java new file mode 100644 index 00000000..8c2adc9d --- /dev/null +++ b/portal-BE/src/test/java/org/onap/portal/controller/WidgetsCatalogControllerTest.java @@ -0,0 +1,147 @@ +package org.onap.portal.controller; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import javax.transaction.Transactional; +import org.hibernate.Hibernate; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portal.dao.fn.EpWidgetCatalogDao; +import org.onap.portal.domain.db.ep.EpMicroserviceParameter; +import org.onap.portal.domain.db.ep.EpWidgetCatalog; +import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; +import org.onap.portal.domain.db.fn.FnLanguage; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.domain.dto.ecomp.WidgetCatalog; +import org.onap.portal.service.ep.EpMicroserviceParameterService; +import org.onap.portal.service.ep.EpWidgetCatalogParameterService; +import org.onap.portal.service.ep.EpWidgetCatalogService; +import org.onap.portal.service.fn.FnLanguageService; +import org.onap.portal.service.fn.FnUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +@TestPropertySource(locations = "classpath:test.properties") +public class WidgetsCatalogControllerTest { + private UsernamePasswordAuthenticationToken principal = new UsernamePasswordAuthenticationToken("demo", + "demo123"); + @Autowired + WidgetsCatalogController widgetsCatalogController; + @Autowired + FnLanguageService fnLanguageService; + @Autowired + FnUserService fnUserService; + @Autowired + EpWidgetCatalogParameterService epWidgetCatalogParameterService; + @Autowired + EpMicroserviceParameterService epMicroserviceParameterService; + @Autowired + EpWidgetCatalogService epWidgetCatalogService; + + @Test + public void getUserWidgetCatalog() { + List<WidgetCatalog> actual = widgetsCatalogController.getUserWidgetCatalog("demo"); + assertNull(actual); + } + + @Test + public void getWidgetCatalog() { + } + + @Test + public void updateWidgetCatalog() { + } + + @Test + public void deleteOnboardingWidget() { + } + + @Test + public void updateWidgetCatalogWithFiles() { + } + + @Test + public void createWidgetCatalog() { + } + + @Test + public void getWidgetFramework() { + } + + @Test + public void getWidgetController() { + } + + @Test + public void getWidgetCSS() { + } + + @Test + public void getWidgetParameterResult() { + } + + @Test + @Transactional + public void getUserParameterById() { + //Given + EpWidgetCatalog widget = EpWidgetCatalog.builder() + .widgetId(54L) + .wdgName("Name") + .wdgFileLoc("loc") + .allUserFlag(true) + .build(); + epWidgetCatalogService.save(widget); + EpMicroserviceParameter parameter = new EpMicroserviceParameter(); + epMicroserviceParameterService.save(parameter); + FnLanguage language = FnLanguage.builder().languageAlias("TS").languageName("TEST").build(); + fnLanguageService.save(principal, language); + FnUser user = buildFnUser(); + language.setFnUsers(new HashSet<>(Collections.singleton(user))); + user.setLanguageId(language); + EpWidgetCatalogParameter data = EpWidgetCatalogParameter.builder() + .widgetId(widget).userId(user).paramId(parameter).userValue("TestData").build(); + //When + epWidgetCatalogParameterService.saveUserParameter(data); + List<EpWidgetCatalogParameter> actual = widgetsCatalogController.getUserParameterById(parameter.getId()); + //Then + assertEquals(1, actual.size()); + //Clean + } + + @Test + public void deleteUserParameterById() { + } + + @Test + public void doDownload() { + } + + @Test + public void saveWidgetParameter() { + } + + @Test + public void getUploadFlag() { + } + + private FnUser buildFnUser(){ + return FnUser.builder() + .lastLoginDate(LocalDateTime.now()) + .activeYn(true) + .modifiedDate(LocalDateTime.now()) + .createdDate(LocalDateTime.now()) + .isInternalYn(true) + .guest(false) + .build(); + } +}
\ No newline at end of file |