summaryrefslogtreecommitdiffstats
path: root/portal-BE/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'portal-BE/src/test/java')
-rw-r--r--portal-BE/src/test/java/org/onap/portal/controller/LanguageControllerTest.java43
-rw-r--r--portal-BE/src/test/java/org/onap/portal/service/fn/FnUserServiceTest.java169
2 files changed, 208 insertions, 4 deletions
diff --git a/portal-BE/src/test/java/org/onap/portal/controller/LanguageControllerTest.java b/portal-BE/src/test/java/org/onap/portal/controller/LanguageControllerTest.java
index 0015c00b..5d89cd0c 100644
--- a/portal-BE/src/test/java/org/onap/portal/controller/LanguageControllerTest.java
+++ b/portal-BE/src/test/java/org/onap/portal/controller/LanguageControllerTest.java
@@ -40,24 +40,27 @@
package org.onap.portal.controller;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.onap.portal.dao.fn.FnLanguageDao;
import org.onap.portal.domain.db.fn.FnLanguage;
+import org.onap.portal.domain.db.fn.FnUser;
import org.onap.portal.domain.dto.PortalRestResponse;
import org.onap.portal.domain.dto.PortalRestStatusEnum;
+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.security.test.context.support.WithMockUser;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringRunner.class)
@SpringBootTest
@TestPropertySource(locations="classpath:test.properties")
+@Transactional
class LanguageControllerTest {
private UsernamePasswordAuthenticationToken principal = new UsernamePasswordAuthenticationToken("demo", "XZa6pS1vC0qKXWtn9wcZWdLx61L0=");
@@ -65,6 +68,8 @@ class LanguageControllerTest {
private LanguageController languageController;
@Autowired
private FnLanguageDao fnLanguageDao;
+ @Autowired
+ private FnUserService fnUserService;
@Test
void saveLanguage() {
@@ -75,9 +80,9 @@ class LanguageControllerTest {
//When
PortalRestResponse<String> expected = new PortalRestResponse<>();
expected.setMessage("SUCCESS");
- expected.setResponse("FnLanguage(languageId=3, languageName=Polish, languageAlias=PL)");
+ expected.setResponse("FnLanguage(languageId=101001, languageName=Polish, languageAlias=PL, fnUsers=[])");
expected.setStatus(PortalRestStatusEnum.OK);
- PortalRestResponse<String> actual = languageController.saveLanguage(principal, fnLanguage);
+ PortalRestResponse<String> actual = languageController.saveLanguage(principal, fnLanguage);
//Then
assertEquals(expected, actual);
@@ -104,4 +109,34 @@ class LanguageControllerTest {
fnLanguageDao.delete(fnLanguage);
}
+ @Test
+ void getLanguageListTest(){
+ assertEquals(languageController.getLanguageList(principal).size(), 2);
+ }
+
+ @Test
+ void setUpUserLanguage(){
+ //Given
+ FnLanguage fnLanguage = new FnLanguage();
+ fnLanguage.setLanguageName("Polish");
+ fnLanguage.setLanguageAlias("PL");
+
+ PortalRestResponse<String> expected = new PortalRestResponse<>();
+ expected.setMessage("SUCCESS");
+ expected.setStatus(PortalRestStatusEnum.OK);
+
+ languageController.saveLanguage(principal, fnLanguage);
+ FnUser fnUser = fnUserService.getUser(1L).get();
+ PortalRestResponse<String> actual = languageController.setUpUserLanguage(principal, fnLanguage, fnUser.getUserId());
+
+ assertEquals(expected, actual);
+ assertEquals(fnUser.getLanguageId(), fnLanguage);
+
+
+ //Clean up
+ fnLanguageDao.delete(fnLanguage);
+ }
+
+
+
} \ No newline at end of file
diff --git a/portal-BE/src/test/java/org/onap/portal/service/fn/FnUserServiceTest.java b/portal-BE/src/test/java/org/onap/portal/service/fn/FnUserServiceTest.java
new file mode 100644
index 00000000..fef9187f
--- /dev/null
+++ b/portal-BE/src/test/java/org/onap/portal/service/fn/FnUserServiceTest.java
@@ -0,0 +1,169 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+
+package org.onap.portal.service.fn;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.time.LocalDateTime;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.onap.portal.domain.db.fn.FnLanguage;
+import org.onap.portal.domain.db.fn.FnLuTimezone;
+import org.onap.portal.domain.db.fn.FnUser;
+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;
+import org.springframework.transaction.annotation.Transactional;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@TestPropertySource(locations="classpath:test.properties")
+@Transactional
+class FnUserServiceTest {
+ private UsernamePasswordAuthenticationToken principal = new UsernamePasswordAuthenticationToken("demo", "XZa6pS1vC0qKXWtn9wcZWdLx61L0=");
+ @Autowired
+ private FnUserService fnUserService;
+ @Autowired
+ private FnLuTimezoneService fnLuTimezoneService;
+ @Autowired
+ private FnLanguageService fnLanguageService;
+
+ @Test
+ void saveUser(){
+ FnUser actual = fnUserService.getUser(1L).get();
+
+ FnUser expected = new FnUser();
+ expected.setUserId(123L);
+ expected.setFirstName("Demo");
+ expected.setLastName("User");
+ expected.setEmail("demo@openecomp.org");
+ expected.setOrgUserId("demo");
+ expected.setTimezone(fnLuTimezoneService.getById(10).orElse(new FnLuTimezone()));
+ expected.setLoginId("demo");
+ expected.setLoginPwd("4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=");
+ expected.setLastLoginDate(LocalDateTime.parse("2019-08-08T12:18:17"));
+ expected.setActiveYn("Y");
+ expected.setCreatedDate(LocalDateTime.parse("2016-10-14T21:00"));
+ expected.setModifiedId(actual);
+ expected.setModifiedDate(LocalDateTime.parse("2019-08-08T12:18:17"));
+ expected.setIsInternalYn("N");
+ expected.setStateCd("NJ");
+ expected.setCountryCd("US");
+ expected.setLanguageId(fnLanguageService.findById(1L).orElse(new FnLanguage()));
+
+ fnUserService.saveFnUser(principal, expected);
+
+ //Clean up
+ fnUserService.deleteUser(expected);
+ }
+
+ @Test
+ void getUser() {
+ FnUser actual = fnUserService.getUser(1L).get();
+
+
+ FnUser expected = new FnUser();
+ expected.setUserId(1L);
+ expected.setFirstName("Demo");
+ expected.setLastName("User");
+ expected.setEmail("demo@openecomp.org");
+ expected.setOrgUserId("demo");
+ expected.setLoginId("demo");
+ expected.setLoginPwd("4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=");
+ expected.setLastLoginDate(LocalDateTime.parse("2019-08-08T12:18:17"));
+ expected.setActiveYn("Y");
+ expected.setCreatedDate(LocalDateTime.parse("2016-10-14T21:00"));
+ expected.setModifiedId(actual);
+ expected.setModifiedDate(LocalDateTime.parse("2019-08-08T12:18:17"));
+ expected.setIsInternalYn("N");
+ expected.setStateCd("NJ");
+ expected.setCountryCd("US");
+ expected.setTimezone(fnLuTimezoneService.getById(10).orElse(new FnLuTimezone()));
+ expected.setLanguageId(fnLanguageService.findById(1L).orElse(new FnLanguage()));
+
+
+ assertEquals(expected.getUserId(), actual.getUserId());
+ assertEquals(expected.getOrgId(), actual.getOrgId());
+ assertEquals(expected.getManagerId(), actual.getManagerId());
+ assertEquals(expected.getFirstName(), actual.getFirstName());
+ assertEquals(expected.getMiddleName(), actual.getMiddleName());
+ assertEquals(expected.getLastName(), actual.getLastName());
+ assertEquals(expected.getPhone(), actual.getPhone());
+ assertEquals(expected.getFax(), actual.getFax());
+ assertEquals(expected.getCellular(), actual.getCellular());
+ assertEquals(expected.getEmail(), actual.getEmail());
+ assertEquals(expected.getAddressId(), actual.getAddressId());
+ assertEquals(expected.getAlertMethodCd(), actual.getAlertMethodCd());
+ assertEquals(expected.getHrid(), actual.getHrid());
+ assertEquals(expected.getOrgUserId(), actual.getOrgUserId());
+ assertEquals(expected.getOrg_code(), actual.getOrg_code());
+ assertEquals(expected.getLoginId(), actual.getLoginId());
+ assertEquals(expected.getLoginPwd(), actual.getLoginPwd());
+ assertEquals(expected.getLastLoginDate(), actual.getLastLoginDate());
+ assertEquals(expected.getActiveYn(), actual.getActiveYn());
+ assertEquals(expected.getCreatedId(), actual.getCreatedId());
+ assertEquals(expected.getCreatedDate(), actual.getCreatedDate());
+ assertEquals(expected.getModifiedId(), actual.getModifiedId());
+ assertEquals(expected.getModifiedDate(), actual.getModifiedDate());
+ assertEquals(expected.getIsInternalYn(), actual.getIsInternalYn());
+ assertEquals(expected.getAddressLine1(), actual.getAddressLine1());
+ assertEquals(expected.getAddressLine2(), actual.getAddressLine2());
+ assertEquals(expected.getCity(), actual.getCity());
+ assertEquals(expected.getStateCd(), actual.getStateCd());
+ assertEquals(expected.getZipCode(), actual.getZipCode());
+ assertEquals(expected.getCountryCd(), actual.getCountryCd());
+ assertEquals(expected.getLocationClli(), actual.getLocationClli());
+ assertEquals(expected.getOrgManagerUserId(), actual.getOrgManagerUserId());
+ assertEquals(expected.getCompany(), actual.getCompany());
+ assertEquals(expected.getDepartmentName(), actual.getDepartmentName());
+ assertEquals(expected.getJobTitle(), actual.getJobTitle());
+ assertEquals(expected.getTimezone().getTimezoneId(), actual.getTimezone().getTimezoneId());
+ assertEquals(expected.getDepartment(), actual.getDepartment());
+ assertEquals(expected.getBusinessUnit(), actual.getBusinessUnit());
+ assertEquals(expected.getBusinessUnitName(), actual.getBusinessUnitName());
+ assertEquals(expected.getCost_center(), actual.getCost_center());
+ assertEquals(expected.getFinLocCode(), actual.getFinLocCode());
+ assertEquals(expected.getSiloStatus(), actual.getSiloStatus());
+ assertEquals(expected.getLanguageId(), actual.getLanguageId());
+ }
+} \ No newline at end of file