first commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class DepartmentTest {
|
||||
|
||||
// テストデータの用意
|
||||
final static Department departmentTest = new Department(
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getNmDepartment()
|
||||
);
|
||||
|
||||
// テストデータの用意
|
||||
final static Department departmentNull = new Department(
|
||||
DepartmentEnum.NULL_DEPARTMENT.getIdDepartment(),
|
||||
DepartmentEnum.NULL_DEPARTMENT.getNmDepartment()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
// 期待値
|
||||
Integer expected = DepartmentEnum.TEST_DEPARTMENT.getIdDepartment();
|
||||
// 実測値
|
||||
Integer actual = departmentTest.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
|
||||
Integer expected = DepartmentEnum.NULL_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = departmentNull.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetNmDepartmentTest {
|
||||
|
||||
@Test
|
||||
void getNmDepartment_正常系_NmDepartmentの取得() {
|
||||
|
||||
String expected = DepartmentEnum.TEST_DEPARTMENT.getNmDepartment();
|
||||
String actual = departmentTest.getNmDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmDepartment_正常系_NmDepartmentの取得結果がnull() {
|
||||
|
||||
String expected = DepartmentEnum.NULL_DEPARTMENT.getNmDepartment();
|
||||
String actual = departmentNull.getNmDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class EmployeeInfoTest {
|
||||
|
||||
static EmployeeInfo testEmployeeInfo = new EmployeeInfo(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()
|
||||
);
|
||||
|
||||
static EmployeeInfo nullEmployeeInfo = new EmployeeInfo(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getEmployeeInstance(),
|
||||
DepartmentEnum.NULL_DEPARTMENT.getDepartmentInstance()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class getIdEmployeeTest {
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = testEmployeeInfo.getEmployee().getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = nullEmployeeInfo.getEmployee().getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class getNmEmployeeTest {
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee();
|
||||
String actual = testEmployeeInfo.getEmployee().getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getNmEmployee();
|
||||
String actual = nullEmployeeInfo.getEmployee().getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetKnEmployeeTest {
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee();
|
||||
String actual = testEmployeeInfo.getEmployee().getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getKnEmployee();
|
||||
String actual = nullEmployeeInfo.getEmployee().getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress();
|
||||
String actual = testEmployeeInfo.getEmployee().getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getMailAddress();
|
||||
String actual = nullEmployeeInfo.getEmployee().getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetPasswordTest {
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getPassword();
|
||||
String actual = testEmployeeInfo.getEmployee().getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getPassword();
|
||||
String actual = nullEmployeeInfo.getEmployee().getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetAdminAuthTest {
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = testEmployeeInfo.getEmployee().getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = nullEmployeeInfo.getEmployee().getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
Integer expected = DepartmentEnum.TEST_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = testEmployeeInfo.getDepartment().getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
Integer expected = DepartmentEnum.NULL_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = nullEmployeeInfo.getDepartment().getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetNmDepartmentTest {
|
||||
@Test
|
||||
void getNmDepartment_正常系_NmDepartmentの取得() {
|
||||
String expected = DepartmentEnum.TEST_DEPARTMENT.getNmDepartment();
|
||||
String actual = testEmployeeInfo.getDepartment().getNmDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmDepartment_正常系_NmDepartmentの取得結果がnull() {
|
||||
String expected = DepartmentEnum.NULL_DEPARTMENT.getNmDepartment();
|
||||
String actual = nullEmployeeInfo.getDepartment().getNmDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class EmployeeSearchTest {
|
||||
|
||||
static SearchConditionEmployee testSearchConditionEmployee = new SearchConditionEmployee(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
static SearchConditionEmployee nullSearchConditionEmployee = new SearchConditionEmployee(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class getIdEmployeeTest {
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = testSearchConditionEmployee.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = nullSearchConditionEmployee.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class getNmEmployeeTest {
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee();
|
||||
String actual = testSearchConditionEmployee.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getNmEmployee();
|
||||
String actual = nullSearchConditionEmployee.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetKnEmployeeTest {
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee();
|
||||
String actual = testSearchConditionEmployee.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getKnEmployee();
|
||||
String actual = nullSearchConditionEmployee.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress();
|
||||
String actual = testSearchConditionEmployee.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getMailAddress();
|
||||
String actual = nullSearchConditionEmployee.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment();
|
||||
Integer actual = testSearchConditionEmployee.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdDepartment();
|
||||
Integer actual = nullSearchConditionEmployee.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class EmployeeTest {
|
||||
|
||||
final static Employee employeeTest = new Employee(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
final static Employee employeeNull = new Employee(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class getIdEmployeeTest {
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = employeeTest.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = employeeNull.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class getNmEmployeeTest {
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee();
|
||||
String actual = employeeTest.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getNmEmployee();
|
||||
String actual = employeeNull.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetKnEmployeeTest {
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee();
|
||||
String actual = employeeTest.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getKnEmployee();
|
||||
String actual = employeeNull.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress();
|
||||
String actual = employeeTest.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getMailAddress();
|
||||
String actual = employeeNull.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetPasswordTest {
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getPassword();
|
||||
String actual = employeeTest.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getPassword();
|
||||
String actual = employeeNull.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetAdminAuthTest {
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = employeeTest.getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = employeeNull.getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment();
|
||||
Integer actual = employeeTest.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdDepartment();
|
||||
Integer actual = employeeNull.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class LoginInfoTest {
|
||||
|
||||
static LoginInfo testLoginInfo = new LoginInfo("aaa", "bbb");
|
||||
static LoginInfo nullLoginInfo = new LoginInfo(null, null);
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = "aaa";
|
||||
String actual = testLoginInfo.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = null;
|
||||
String actual = nullLoginInfo.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetPasswordTest {
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得() {
|
||||
String expected = "bbb";
|
||||
String actual = testLoginInfo.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得結果がnull() {
|
||||
String expected = null;
|
||||
String actual = nullLoginInfo.getPassword();
|
||||
;
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class LoginUserTest {
|
||||
|
||||
static LoginUser adminLoginUser = new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
static LoginUser normalLoginUser = new LoginUser(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
static LoginUser nullLoginUser = new LoginUser(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class getIdEmployeeTest {
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = adminLoginUser.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = nullLoginUser.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class getNmEmployeeTest {
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee();
|
||||
String actual = adminLoginUser.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getNmEmployee();
|
||||
String actual = nullLoginUser.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetKnEmployeeTest {
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee();
|
||||
String actual = adminLoginUser.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getKnEmployee();
|
||||
String actual = nullLoginUser.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress();
|
||||
String actual = adminLoginUser.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getMailAddress();
|
||||
String actual = nullLoginUser.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetPasswordTest {
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getPassword();
|
||||
String actual = adminLoginUser.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getPassword();
|
||||
String actual = nullLoginUser.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetAdminAuthTest {
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = adminLoginUser.getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = nullLoginUser.getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
Integer expected = DepartmentEnum.TEST_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = adminLoginUser.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
Integer expected = DepartmentEnum.NULL_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = nullLoginUser.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class IsAdminUserTest {
|
||||
@Test
|
||||
void isAdminUser_正常系_管理者である() {
|
||||
assertTrue(adminLoginUser.isAdminUser());
|
||||
}
|
||||
|
||||
@Test
|
||||
void isAdminUser_正常系_一般である() {
|
||||
assertFalse(normalLoginUser.isAdminUser());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.infra.record.LoginUserEnum;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DeleteEmployeeTest {
|
||||
|
||||
@Mock
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Mock
|
||||
LoginUser loginUser;
|
||||
|
||||
@Mock
|
||||
Model model;
|
||||
|
||||
@InjectMocks
|
||||
DeleteEmployeeImpl deleteEmployeeImpl;
|
||||
|
||||
@Nested
|
||||
public class deleteExecTest {
|
||||
@Test
|
||||
public void deleteExec_正常系_アカウントの削除成功() {
|
||||
doNothing().when(employeeRepository).deleteById(any());
|
||||
deleteEmployeeImpl.deleteEmployee(LoginUserEnum.NORMAL_LOGIN_USER.getIdEmployee());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.infra.record.LoginUserEnum;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class LoginImplTest {
|
||||
|
||||
@Mock
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@InjectMocks
|
||||
LoginImpl login;
|
||||
|
||||
@Nested
|
||||
class doLoginTest {
|
||||
@Test
|
||||
void doLogin_正常系_ログイン者情報取得() {
|
||||
when(employeeRepository.findByMailAddressAndPassword(anyString(), anyString()))
|
||||
.thenReturn(
|
||||
Optional.of(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
)));
|
||||
|
||||
LoginUser actual = login.doLogin(new LoginInfo(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), EmployeeEnum.ADMIN_EMPLOYEE.getPassword()));
|
||||
LoginUser expected = LoginUserEnum.ADMIN_LOGIN_USER.getLoginUserInstance();
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.getIdDepartment())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void doLogin_正常系_ログイン者情報該当なし() {
|
||||
when(employeeRepository.findByMailAddressAndPassword(anyString(), anyString()))
|
||||
.thenReturn(Optional.empty());
|
||||
|
||||
|
||||
LoginUser actual = login.doLogin(new LoginInfo(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), EmployeeEnum.ADMIN_EMPLOYEE.getPassword()));
|
||||
|
||||
assertAll(
|
||||
() -> assertNull(actual.getIdEmployee()),
|
||||
() -> assertNull(actual.getNmEmployee()),
|
||||
() -> assertNull(actual.getKnEmployee()),
|
||||
() -> assertNull(actual.getMailAddress()),
|
||||
() -> assertNull(actual.getPassword()),
|
||||
() -> assertNull(actual.getAdminAuth()),
|
||||
() -> assertNull(actual.getIdDepartment())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Nested
|
||||
class canLoginTest {
|
||||
@Test
|
||||
void canLogin_正常系_ログイン可能() {
|
||||
when(employeeRepository.findByMailAddressAndPassword(anyString(), anyString()))
|
||||
.thenReturn(
|
||||
Optional.of(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
)));
|
||||
|
||||
boolean actual = login.canLogin(new LoginInfo(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), EmployeeEnum.ADMIN_EMPLOYEE.getPassword()));
|
||||
|
||||
assertTrue(actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void canLogin_正常系_ログイン不可() {
|
||||
when(employeeRepository.findByMailAddressAndPassword(anyString(), anyString()))
|
||||
.thenReturn(Optional.empty());
|
||||
|
||||
boolean actual = login.canLogin(new LoginInfo(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), EmployeeEnum.ADMIN_EMPLOYEE.getPassword()));
|
||||
|
||||
assertFalse(actual);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class RegisterEmployeeImplTest {
|
||||
|
||||
@InjectMocks
|
||||
RegisterEmployeeImpl registerEmployee;
|
||||
|
||||
@Mock
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Nested
|
||||
class registerEmployeeTest {
|
||||
@Test
|
||||
void registerEmployee() {
|
||||
when(employeeRepository
|
||||
.save(EmployeeEntity
|
||||
.convertFrom(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance())))
|
||||
.thenReturn((EmployeeEntity
|
||||
.convertFrom(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance())));
|
||||
|
||||
registerEmployee
|
||||
.registerEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SearchConditionDepartmentImplTest {
|
||||
|
||||
@InjectMocks
|
||||
SearchDepartmentImpl searchDepartment;
|
||||
|
||||
@Mock
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
@Nested
|
||||
class selectAllTest {
|
||||
@Test
|
||||
void selectAll_正常系_1件以上() {
|
||||
Department department = DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance();
|
||||
DepartmentEntity departmentEntity = new DepartmentEntity(department.getIdDepartment(), department.getNmDepartment());
|
||||
|
||||
when(departmentRepository.findAll())
|
||||
.thenReturn(List.of(departmentEntity));
|
||||
|
||||
List<Department> actual = searchDepartment.selectAll();
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(department.getIdDepartment(), actual.get(0).getIdDepartment()),
|
||||
() -> assertEquals(department.getNmDepartment(), actual.get(0).getNmDepartment())
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectAll_正常系_0件() {
|
||||
|
||||
when(departmentRepository.findAll())
|
||||
.thenReturn(List.of(new DepartmentEntity()));
|
||||
|
||||
List<Department> actual = searchDepartment.selectAll();
|
||||
|
||||
assertAll(
|
||||
() -> assertNull(actual.get(0).getIdDepartment()),
|
||||
() -> assertNull(actual.get(0).getNmDepartment())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SearchEmployeeImplTest {
|
||||
|
||||
@InjectMocks
|
||||
SearchEmployeeImpl searchEmployee;
|
||||
|
||||
@Mock
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Nested
|
||||
class searchEmployeeTest {
|
||||
@Test
|
||||
void searchEmployee_正常系_1件以上() {
|
||||
when(employeeRepository
|
||||
.findByMailAddress(anyString()))
|
||||
.thenReturn(
|
||||
Optional.of(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
)));
|
||||
|
||||
List<Employee> actual = searchEmployee.searchEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress());
|
||||
Employee expected = EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance();
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.get(0).getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.get(0).getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.get(0).getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.get(0).getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.get(0).getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.get(0).getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.get(0).getIdDepartment())
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void searchEmployee_正常系_0件() {
|
||||
when(employeeRepository
|
||||
.findByMailAddress(anyString()))
|
||||
.thenReturn(Optional.empty());
|
||||
|
||||
List<Employee> actual = searchEmployee.searchEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress());
|
||||
|
||||
assertTrue(actual.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class searchLoginUserTest {
|
||||
@Test
|
||||
void searchLoginUser_正常系_1件以上() {
|
||||
|
||||
when(employeeRepository
|
||||
.findByMailAddress(anyString()))
|
||||
.thenReturn(
|
||||
Optional.of(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
)));
|
||||
|
||||
LoginUser actual = searchEmployee.searchLoginUser(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress());
|
||||
Employee expected = EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance();
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.getIdDepartment())
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void searchLoginUser_正常系_0件() {
|
||||
when(employeeRepository
|
||||
.findByMailAddress(anyString()))
|
||||
.thenReturn(Optional.empty());
|
||||
|
||||
LoginUser actual = searchEmployee.searchLoginUser(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress());
|
||||
|
||||
assertAll(
|
||||
() -> assertNull(actual.getIdEmployee()),
|
||||
() -> assertNull(actual.getNmEmployee()),
|
||||
() -> assertNull(actual.getKnEmployee()),
|
||||
() -> assertNull(actual.getMailAddress()),
|
||||
() -> assertNull(actual.getPassword()),
|
||||
() -> assertNull(actual.getAdminAuth()),
|
||||
() -> assertNull(actual.getIdDepartment())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
class searchEmployeeByIdEmployeeTest {
|
||||
@Test
|
||||
void searchEmployeeByIdEmployee_正常系_該当あり() {
|
||||
when(employeeRepository
|
||||
.findByIdEmployee(any()))
|
||||
.thenReturn(
|
||||
Optional.of(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
)));
|
||||
|
||||
Employee actual = searchEmployee.searchEmployeeByIdEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee());
|
||||
Employee expected = EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance();
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.getIdDepartment())
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void searchEmployeeByIdEmployee_正常系_該当なし() {
|
||||
when(employeeRepository
|
||||
.findByIdEmployee(any()))
|
||||
.thenReturn(Optional.empty());
|
||||
|
||||
Employee actual = searchEmployee.searchEmployeeByIdEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee());
|
||||
|
||||
assertAll(
|
||||
() -> assertNull(actual.getIdEmployee()),
|
||||
() -> assertNull(actual.getNmEmployee()),
|
||||
() -> assertNull(actual.getKnEmployee()),
|
||||
() -> assertNull(actual.getMailAddress()),
|
||||
() -> assertNull(actual.getPassword()),
|
||||
() -> assertNull(actual.getAdminAuth()),
|
||||
() -> assertNull(actual.getIdDepartment())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SearchEmployeeInfoImplTest {
|
||||
|
||||
@InjectMocks
|
||||
SearchEmployeeInfoImpl searchEmployeeInfo;
|
||||
|
||||
@Mock
|
||||
EmployeeInfoRepository employeeInfoRepository;
|
||||
|
||||
@Nested
|
||||
class selectAllTest {
|
||||
@Test
|
||||
void selectAll_正常系_1件以上() {
|
||||
Employee employee = EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance();
|
||||
Department department = DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance();
|
||||
|
||||
when(employeeInfoRepository.findAll())
|
||||
.thenReturn(List.of(
|
||||
new EmployeeDepartmentEntity(
|
||||
employee.getIdEmployee(),
|
||||
employee.getNmEmployee(),
|
||||
employee.getKnEmployee(),
|
||||
employee.getMailAddress(),
|
||||
employee.getPassword(),
|
||||
employee.getAdminAuth(),
|
||||
new DepartmentEntity(department.getIdDepartment(), department.getNmDepartment())
|
||||
)
|
||||
));
|
||||
|
||||
EmployeeInfo expected = new EmployeeInfo(
|
||||
employee,
|
||||
department
|
||||
);
|
||||
|
||||
List<EmployeeInfo> actual = searchEmployeeInfo.selectAll();
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getEmployee().getIdEmployee(), actual.get(0).getEmployee().getIdEmployee()),
|
||||
() -> assertEquals(expected.getEmployee().getNmEmployee(), actual.get(0).getEmployee().getNmEmployee()),
|
||||
() -> assertEquals(expected.getEmployee().getKnEmployee(), actual.get(0).getEmployee().getKnEmployee()),
|
||||
() -> assertEquals(expected.getEmployee().getMailAddress(), actual.get(0).getEmployee().getMailAddress()),
|
||||
() -> assertEquals(expected.getEmployee().getPassword(), actual.get(0).getEmployee().getPassword()),
|
||||
() -> assertEquals(expected.getEmployee().getAdminAuth(), actual.get(0).getEmployee().getAdminAuth()),
|
||||
() -> assertEquals(expected.getDepartment().getIdDepartment(), actual.get(0).getDepartment().getIdDepartment()),
|
||||
() -> assertEquals(expected.getDepartment().getNmDepartment(), actual.get(0).getDepartment().getNmDepartment())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectAll_正常系_0件() {
|
||||
Employee employee = EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance();
|
||||
Department department = DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance();
|
||||
|
||||
when(employeeInfoRepository.findAll())
|
||||
.thenReturn(List.of(new EmployeeDepartmentEntity()));
|
||||
|
||||
EmployeeInfo expected = new EmployeeInfo(
|
||||
employee,
|
||||
department
|
||||
);
|
||||
|
||||
List<EmployeeInfo> actual = searchEmployeeInfo.selectAll();
|
||||
|
||||
assertAll(
|
||||
() -> assertNull(actual.get(0).getEmployee().getIdEmployee()),
|
||||
() -> assertNull(actual.get(0).getEmployee().getNmEmployee()),
|
||||
() -> assertNull(actual.get(0).getEmployee().getKnEmployee()),
|
||||
() -> assertNull(actual.get(0).getEmployee().getMailAddress()),
|
||||
() -> assertNull(actual.get(0).getEmployee().getPassword()),
|
||||
() -> assertNull(actual.get(0).getEmployee().getAdminAuth()),
|
||||
() -> assertNull(actual.get(0).getDepartment().getIdDepartment()),
|
||||
() -> assertNull(actual.get(0).getDepartment().getNmDepartment())
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class searchByTest {
|
||||
@Test
|
||||
void searchBy_正常系_検索結果あり() {
|
||||
when(employeeInfoRepository.findAll(any(Specification.class)))
|
||||
.thenReturn(List.of(new EmployeeDepartmentEntity(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
new DepartmentEntity(
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getNmDepartment()
|
||||
)
|
||||
)));
|
||||
|
||||
EmployeeInfo expected = new EmployeeInfo(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()
|
||||
);
|
||||
|
||||
List<EmployeeInfo> actual = searchEmployeeInfo.searchBy(
|
||||
new SearchConditionEmployee(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()
|
||||
)
|
||||
);
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getEmployee().getIdEmployee(), actual.get(0).getEmployee().getIdEmployee()),
|
||||
() -> assertEquals(expected.getEmployee().getNmEmployee(), actual.get(0).getEmployee().getNmEmployee()),
|
||||
() -> assertEquals(expected.getEmployee().getKnEmployee(), actual.get(0).getEmployee().getKnEmployee()),
|
||||
() -> assertEquals(expected.getEmployee().getMailAddress(), actual.get(0).getEmployee().getMailAddress()),
|
||||
() -> assertEquals(expected.getEmployee().getPassword(), actual.get(0).getEmployee().getPassword()),
|
||||
() -> assertEquals(expected.getEmployee().getAdminAuth(), actual.get(0).getEmployee().getAdminAuth()),
|
||||
() -> assertEquals(expected.getDepartment().getIdDepartment(), actual.get(0).getDepartment().getIdDepartment()),
|
||||
() -> assertEquals(expected.getDepartment().getNmDepartment(), actual.get(0).getDepartment().getNmDepartment())
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void searchBy_正常系_検索結果なし() {
|
||||
when(employeeInfoRepository.findAll(any(Specification.class)))
|
||||
.thenReturn(List.of());
|
||||
|
||||
assertTrue(searchEmployeeInfo.searchBy(
|
||||
new SearchConditionEmployee(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()
|
||||
)
|
||||
).isEmpty());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class UpdateEmployeeImplTest {
|
||||
@InjectMocks
|
||||
UpdateEmployeeImpl updateEmployee;
|
||||
|
||||
@Mock
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
|
||||
@Nested
|
||||
class updateEmployeeTest {
|
||||
@Test
|
||||
void updateEmployee_正常系_更新() {
|
||||
when(employeeRepository.save(any()))
|
||||
.thenReturn(null);
|
||||
updateEmployee.updateEmployee(new Employee(
|
||||
1,
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
1,
|
||||
1
|
||||
), new Employee(
|
||||
1,
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
1,
|
||||
1
|
||||
));
|
||||
assertTrue(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DepartmentEntityTest {
|
||||
|
||||
DepartmentEntity expected;
|
||||
|
||||
|
||||
@Nested
|
||||
class createDepartmentListTest {
|
||||
@Test
|
||||
void createDepartmentList_正常系_変換() {
|
||||
expected = new DepartmentEntity(
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getNmDepartment()
|
||||
);
|
||||
List<Department> actual = DepartmentEntity.createDepartmentList(List.of(expected));
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.get(0).getIdDepartment()),
|
||||
() -> assertEquals(expected.getNmDepartment(), actual.get(0).getNmDepartment())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class EmployeeDepartmentEntityTest {
|
||||
|
||||
@Nested
|
||||
class createEmployeeInfoTest {
|
||||
@Test
|
||||
void createEmployeeInfo_正常系() {
|
||||
EmployeeInfo employeeInfo = EmployeeDepartmentEntity.createEmployeeInfo(
|
||||
new EmployeeDepartmentEntity(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
new DepartmentEntity(
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getNmDepartment()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(), employeeInfo.getEmployee().getIdEmployee()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(), employeeInfo.getEmployee().getNmEmployee()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(), employeeInfo.getEmployee().getKnEmployee()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), employeeInfo.getEmployee().getMailAddress()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getPassword(), employeeInfo.getEmployee().getPassword()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(), employeeInfo.getEmployee().getAdminAuth()),
|
||||
() -> assertEquals(DepartmentEnum.TEST_DEPARTMENT.getIdDepartment(), employeeInfo.getDepartment().getIdDepartment()),
|
||||
() -> assertEquals(DepartmentEnum.TEST_DEPARTMENT.getNmDepartment(), employeeInfo.getDepartment().getNmDepartment())
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class createEmployeeInfoListTest {
|
||||
@Test
|
||||
void createEmployeeInfoList_正常系() {
|
||||
EmployeeInfo employeeInfo = EmployeeDepartmentEntity.createEmployeeInfoList(
|
||||
List.of(new EmployeeDepartmentEntity(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
new DepartmentEntity(
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getNmDepartment()
|
||||
)
|
||||
))).get(0);
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(), employeeInfo.getEmployee().getIdEmployee()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(), employeeInfo.getEmployee().getNmEmployee()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(), employeeInfo.getEmployee().getKnEmployee()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), employeeInfo.getEmployee().getMailAddress()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getPassword(), employeeInfo.getEmployee().getPassword()),
|
||||
() -> assertEquals(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(), employeeInfo.getEmployee().getAdminAuth()),
|
||||
() -> assertEquals(DepartmentEnum.TEST_DEPARTMENT.getIdDepartment(), employeeInfo.getDepartment().getIdDepartment()),
|
||||
() -> assertEquals(DepartmentEnum.TEST_DEPARTMENT.getNmDepartment(), employeeInfo.getDepartment().getNmDepartment())
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class EmployeeEntityTest {
|
||||
|
||||
@Nested
|
||||
class createEmployeeTest {
|
||||
@Test
|
||||
void createEmployee_正常系_変換() {
|
||||
EmployeeEntity expected = new EmployeeEntity(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
Employee actual = EmployeeEntity.createEmployee(
|
||||
expected
|
||||
);
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.getIdDepartment())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class createEmployeeListTest {
|
||||
@Test
|
||||
void createEmployeeList_正常系_変換() {
|
||||
EmployeeEntity expected = new EmployeeEntity(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
List<Employee> actual = EmployeeEntity.createEmployeeList(List.of(expected));
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.get(0).getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.get(0).getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.get(0).getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.get(0).getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.get(0).getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.get(0).getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.get(0).getIdDepartment())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class createLoginUserTest {
|
||||
@Test
|
||||
void createLoginUser_正常系_変換() {
|
||||
EmployeeEntity expected = new EmployeeEntity(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
LoginUser actual = expected.createLoginUser();
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.getIdDepartment())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class convertFromTest {
|
||||
@Test
|
||||
void convertFrom_正常系_変換_社員() {
|
||||
Employee expected = new Employee(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
EmployeeEntity actual = EmployeeEntity.convertFrom(expected);
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.getIdDepartment())
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void convertFrom_正常系_変換_検索() {
|
||||
SearchConditionEmployee expected = new SearchConditionEmployee(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
EmployeeEntity actual = EmployeeEntity.convertFrom(expected);
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.getMailAddress()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.getIdDepartment())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.example.rhizome.app.infra.record;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
|
||||
public enum DepartmentEnum {
|
||||
|
||||
TEST_DEPARTMENT(10000, "テスト部署"),
|
||||
NULL_DEPARTMENT(null, null);
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
|
||||
DepartmentEnum(Integer idDepartment, String nmDepartment) {
|
||||
this.idDepartment = idDepartment;
|
||||
this.nmDepartment = nmDepartment;
|
||||
}
|
||||
|
||||
|
||||
public Integer getIdDepartment() {
|
||||
return idDepartment;
|
||||
}
|
||||
|
||||
public String getNmDepartment() {
|
||||
return nmDepartment;
|
||||
}
|
||||
|
||||
public Department getDepartmentInstance() {
|
||||
return new Department(getIdDepartment(), getNmDepartment());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.example.rhizome.app.infra.record;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
|
||||
public enum EmployeeEnum {
|
||||
|
||||
ADMIN_EMPLOYEE(
|
||||
90000,
|
||||
"テスト太郎",
|
||||
"テストタロウカナ",
|
||||
"test@mail.com",
|
||||
"password",
|
||||
1,
|
||||
10000),
|
||||
NORMAL_EMPLOYEE(
|
||||
90001,
|
||||
"テスト一般太郎",
|
||||
"テストイッパンタロウカナ",
|
||||
"test-normal@mail.com",
|
||||
"password-normal",
|
||||
0,
|
||||
10000),
|
||||
NULL_EMPLOYEE(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private final String password;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private final Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
EmployeeEnum(Integer idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password, Integer adminAuth, Integer idDepartment) {
|
||||
this.idEmployee = idEmployee;
|
||||
this.nmEmployee = nmEmployee;
|
||||
this.knEmployee = knEmployee;
|
||||
this.mailAddress = mailAddress;
|
||||
this.password = password;
|
||||
this.adminAuth = adminAuth;
|
||||
this.idDepartment = idDepartment;
|
||||
}
|
||||
|
||||
public Integer getIdEmployee() {
|
||||
return idEmployee;
|
||||
}
|
||||
|
||||
public String getNmEmployee() {
|
||||
return nmEmployee;
|
||||
}
|
||||
|
||||
public String getKnEmployee() {
|
||||
return knEmployee;
|
||||
}
|
||||
|
||||
public String getMailAddress() {
|
||||
return mailAddress;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public Integer getAdminAuth() {
|
||||
return adminAuth;
|
||||
}
|
||||
|
||||
public Integer getIdDepartment() {
|
||||
return idDepartment;
|
||||
}
|
||||
|
||||
public Employee getEmployeeInstance() {
|
||||
return new Employee(
|
||||
getIdEmployee(),
|
||||
getNmEmployee(),
|
||||
getKnEmployee(),
|
||||
getMailAddress(),
|
||||
getPassword(),
|
||||
getAdminAuth(),
|
||||
getIdDepartment()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.example.rhizome.app.infra.record;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
public enum EmployeeSearchEnum {
|
||||
ADMIN_EMPLOYEE_SEARCH(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
),
|
||||
NORMAL_EMPLOYEE_SEARCH(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getIdDepartment()
|
||||
),
|
||||
NULL_EMPLOYEE_SEARCH(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
EmployeeSearchEnum(Integer idEmployee, String nmEmployee, String knEmployee, String mailAddress, Integer idDepartment) {
|
||||
this.idEmployee = idEmployee;
|
||||
this.nmEmployee = nmEmployee;
|
||||
this.knEmployee = knEmployee;
|
||||
this.mailAddress = mailAddress;
|
||||
this.idDepartment = idDepartment;
|
||||
}
|
||||
|
||||
public Integer getIdEmployee() {
|
||||
return idEmployee;
|
||||
}
|
||||
|
||||
public String getNmEmployee() {
|
||||
return nmEmployee;
|
||||
}
|
||||
|
||||
public String getKnEmployee() {
|
||||
return knEmployee;
|
||||
}
|
||||
|
||||
public String getMailAddress() {
|
||||
return mailAddress;
|
||||
}
|
||||
|
||||
public Integer getIdDepartment() {
|
||||
return idDepartment;
|
||||
}
|
||||
|
||||
public SearchConditionEmployee getEmployeeSearchInstance() {
|
||||
return new SearchConditionEmployee(
|
||||
getIdEmployee(),
|
||||
getNmEmployee(),
|
||||
getKnEmployee(),
|
||||
getMailAddress(),
|
||||
getIdDepartment()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.example.rhizome.app.infra.record;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
public enum LoginUserEnum {
|
||||
|
||||
ADMIN_LOGIN_USER(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
),
|
||||
|
||||
NORMAL_LOGIN_USER(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private final String password;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private final Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
LoginUserEnum(
|
||||
Integer idEmployee,
|
||||
String nmEmployee,
|
||||
String knEmployee,
|
||||
String mailAddress,
|
||||
String password,
|
||||
Integer adminAuth,
|
||||
Integer idDepartment
|
||||
) {
|
||||
this.idEmployee = idEmployee;
|
||||
this.nmEmployee = nmEmployee;
|
||||
this.knEmployee = knEmployee;
|
||||
this.mailAddress = mailAddress;
|
||||
this.password = password;
|
||||
this.adminAuth = adminAuth;
|
||||
this.idDepartment = idDepartment;
|
||||
|
||||
}
|
||||
|
||||
public Integer getIdEmployee() {
|
||||
return idEmployee;
|
||||
}
|
||||
|
||||
public String getNmEmployee() {
|
||||
return nmEmployee;
|
||||
}
|
||||
|
||||
public String getKnEmployee() {
|
||||
return knEmployee;
|
||||
}
|
||||
|
||||
public String getMailAddress() {
|
||||
return mailAddress;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public Integer getAdminAuth() {
|
||||
return adminAuth;
|
||||
}
|
||||
|
||||
public Integer getIdDepartment() {
|
||||
return idDepartment;
|
||||
}
|
||||
|
||||
public LoginUser getLoginUserInstance() {
|
||||
return new LoginUser(
|
||||
getIdEmployee(),
|
||||
getNmEmployee(),
|
||||
getKnEmployee(),
|
||||
getMailAddress(),
|
||||
getPassword(),
|
||||
getAdminAuth(),
|
||||
getIdDepartment()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.service.DeleteEmployee;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class DeleteEmployeeControllerTest {
|
||||
|
||||
@MockBean
|
||||
DeleteEmployee deleteEmployee;
|
||||
@MockBean
|
||||
SearchDepartmentImpl searchDepartmentImpl;
|
||||
@MockBean
|
||||
Model model;
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Nested
|
||||
class deleteEmployeeTest {
|
||||
|
||||
@Test
|
||||
void deleteEmployee_正常系_削除() throws Exception {
|
||||
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
doNothing().when(deleteEmployee).deleteEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee());
|
||||
when(searchDepartmentImpl.selectAll()).thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.DELETE_EMPLOYEE)
|
||||
.session(session)
|
||||
.param("idEmployee", "1"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteEmployee_異常系_削除対象が操作者() throws Exception {
|
||||
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
doNothing().when(deleteEmployee).deleteEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee());
|
||||
when(searchDepartmentImpl.selectAll()).thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.DELETE_EMPLOYEE)
|
||||
.session(session)
|
||||
.param("idEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee().toString()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name("forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class IndexControllerTest {
|
||||
|
||||
@MockBean
|
||||
Model model;
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Nested
|
||||
class indexTest {
|
||||
|
||||
@Test
|
||||
void index_正常系_ログイン画面へ遷移() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(TransitionTargetPageNameKeyword.INDEX_SLASH)
|
||||
.session(session))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.LOGIN_HTML));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchEmployeeImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class InsertEmployeeConfirmControllerTest {
|
||||
|
||||
@MockBean
|
||||
SearchEmployeeImpl searchEmployee;
|
||||
@MockBean
|
||||
SearchDepartmentImpl searchDepartment;
|
||||
@MockBean
|
||||
Model model;
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Nested
|
||||
class insertEmployeeConfirmTest {
|
||||
|
||||
@Test
|
||||
void insertEmployeeConfirm_正常系_登録確認画面へ遷移() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM)
|
||||
.session(session)
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertEmployeeConfirm_異常系_登録情報に誤り() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM)
|
||||
.session(session)
|
||||
.param("nmEmployee", "")
|
||||
.param("knEmployee", "")
|
||||
.param("mailAddress", "")
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", "")
|
||||
.param("adminAuth", "")
|
||||
.param("idDepartment", ""))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertEmployeeConfirm_異常系_登録情報に誤り_パスワード不一致() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM)
|
||||
.session(session)
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", "password123")
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertEmployeeConfirm_異常系_登録情報に誤り_メールアドレス重複() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM)
|
||||
.session(session)
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.service.impl.RegisterEmployeeImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class InsertEmployeeControllerTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
Model model;
|
||||
|
||||
@MockBean
|
||||
SearchDepartmentImpl searchDepartment;
|
||||
|
||||
@MockBean
|
||||
RegisterEmployeeImpl registerEmployee;
|
||||
|
||||
|
||||
@Nested
|
||||
class insertEmployeeTest {
|
||||
@Test
|
||||
void insertEmployee_正常系_登録結果画面へ遷移() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
doNothing().when(registerEmployee).registerEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE)
|
||||
.session(session)
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertEmployee_異常系_登録情報に誤り() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
doNothing().when(registerEmployee).registerEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE)
|
||||
.session(session)
|
||||
.param("nmEmployee", "")
|
||||
.param("knEmployee", "")
|
||||
.param("mailAddress", "")
|
||||
.param("password", "")
|
||||
.param("adminAuth", "")
|
||||
.param("idDepartment", ""))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class InsertEmployeeInputControllerTest {
|
||||
|
||||
@MockBean
|
||||
Model model;
|
||||
@MockBean
|
||||
SearchDepartmentImpl searchDepartment;
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Nested
|
||||
class insertEmployeeInputTest {
|
||||
|
||||
@Test
|
||||
void insertEmployeeInput_正常系_登録画面へ遷移() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT)
|
||||
.session(session)
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.service.impl.LoginImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class LoginControllerTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
LoginImpl login;
|
||||
@MockBean
|
||||
Model model;
|
||||
|
||||
|
||||
@Nested
|
||||
class loginTest {
|
||||
|
||||
@Test
|
||||
void login_正常系_ログイン画面へ遷移() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
|
||||
when(login.canLogin(any())).thenReturn(true);
|
||||
|
||||
when(login.doLogin(any()))
|
||||
.thenReturn(EmployeeEntity.convertFrom(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()).createLoginUser());
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.DO_LOGIN)
|
||||
.session(session)
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.MENU_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void login_正常系_個人情報更新画面() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
|
||||
when(login.canLogin(any())).thenReturn(true);
|
||||
|
||||
when(login.doLogin(any()))
|
||||
.thenReturn(EmployeeEntity.convertFrom(EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()).createLoginUser());
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.DO_LOGIN)
|
||||
.session(session)
|
||||
.param("mailAddress", EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.NORMAL_EMPLOYEE.getPassword()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML));
|
||||
}
|
||||
|
||||
@Test
|
||||
void login_異常系_ログイン不可() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
|
||||
when(login.canLogin(any())).thenReturn(false);
|
||||
|
||||
when(login.doLogin(any()))
|
||||
.thenReturn(EmployeeEntity.convertFrom(EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()).createLoginUser());
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.DO_LOGIN)
|
||||
.session(session)
|
||||
.param("mailAddress", EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.NORMAL_EMPLOYEE.getPassword()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.LOGIN_HTML));
|
||||
}
|
||||
|
||||
@Test
|
||||
void login_異常系_パスワード誤り() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.DO_LOGIN)
|
||||
.session(session)
|
||||
.param("mailAddress", EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress())
|
||||
.param("password", ""))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.LOGIN_HTML));
|
||||
}
|
||||
|
||||
@Test
|
||||
void login_異常系_メールアドレス誤り() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.DO_LOGIN)
|
||||
.session(session)
|
||||
.param("mailAddress", "")
|
||||
.param("password", EmployeeEnum.NORMAL_EMPLOYEE.getPassword()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.LOGIN_HTML));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class LogoutControllerTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
Model model;
|
||||
|
||||
|
||||
@Nested
|
||||
class doLogoutTest {
|
||||
|
||||
@Test
|
||||
void doLogout_正常系_ログアウト() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.LOGOUT)
|
||||
.session(session))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.LOGIN_HTML));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class MenuControllerTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@Nested
|
||||
class showMenuTest {
|
||||
|
||||
@Test
|
||||
void showMenu_正常系_メニュー画面表示() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.SHOW_MENU)
|
||||
.session(session))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.MENU_HTML));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchEmployeeInfoImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class SelectEmployeeControllerTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
Model model;
|
||||
@MockBean
|
||||
SearchDepartmentImpl searchDepartment;
|
||||
@MockBean
|
||||
SearchEmployeeInfoImpl searchEmployeeInfo;
|
||||
|
||||
@Nested
|
||||
class selectTest {
|
||||
@Test
|
||||
void select_正常系_社員検索画面表示() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO)
|
||||
.session(session))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchEmployeeInfoImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class UpdateEmployeeControllerTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
Model model;
|
||||
|
||||
@MockBean
|
||||
SearchDepartmentImpl searchDepartment;
|
||||
@MockBean
|
||||
SearchEmployeeInfoImpl searchEmployeeInfo;
|
||||
|
||||
@Nested
|
||||
class showUpdateEmployeeTest {
|
||||
@Test
|
||||
void showUpdateEmployee_正常系_社員情報更新画面表示() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployeeInfo.searchBy(any()))
|
||||
.thenReturn(List.of(new EmployeeInfo(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()
|
||||
)));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void showUpdateEmployee_異常系_更新対象のデータが存在しない() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployeeInfo.searchBy(any()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name("forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,532 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchEmployeeImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.UpdateEmployeeImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class EmployeeUpdateResultControllerTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
Model model;
|
||||
@MockBean
|
||||
SearchDepartmentImpl searchDepartment;
|
||||
@MockBean
|
||||
SearchEmployeeImpl searchEmployee;
|
||||
@MockBean
|
||||
UpdateEmployeeImpl updateEmployee;
|
||||
|
||||
@Nested
|
||||
class employeeUpdateResultTest {
|
||||
|
||||
@Test
|
||||
void employeeUpdateResult_正常系_社員情報更新結果画面表示_メールアドレス同一人物_権限変更なし() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void employeeUpdateResult_正常系_社員情報更新結果画面表示_メールアドレス同一人物_権限変更なし_パスワード更新なし() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", "")
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEmployeeResult_正常系_社員情報更新結果画面表示_メールアドレス同一人物_権限変更あり_パスワード更新なし_対象者は操作者ではない() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", "")
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEmployeeResult_正常系_社員情報更新結果画面表示_メールアドレス重複無し_権限変更あり_パスワード更新なし_対象者は操作者ではない() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", "")
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEmployeeResult_異常系_パスワードが仕様を満たしていない1() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEmployeeResult_異常系_パスワードが仕様を満たしていない2() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", "")
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEmployeeResult_異常系_メールアドレス重複_権限変更なし() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.NORMAL_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEmployeeResult_異常系_同一人物_操作者の権限変更あり() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEmployeeResult_異常系_画面からのパラメータ異常() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", "")
|
||||
.param("knEmployee", "")
|
||||
.param("mailAddress", "")
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", "")
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEmployeeResult_異常系_更新前のデータが存在しない() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
when(searchDepartment.selectAll())
|
||||
.thenReturn(List.of(DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
when(searchEmployee.searchEmployeeByIdEmployee(any()))
|
||||
.thenReturn(EmployeeEntity.createEmployee(new EmployeeEntity()));
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment()));
|
||||
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", EmployeeEnum.ADMIN_EMPLOYEE.getPassword())
|
||||
.param("adminAuth", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth()))
|
||||
.param("idDepartment", String.valueOf(EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment())))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchEmployeeImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.UpdateEmployeeImpl;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class UpdatePersonalEmployeeResultControllerTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
Model model;
|
||||
@MockBean
|
||||
SearchEmployeeImpl searchEmployee;
|
||||
@MockBean
|
||||
UpdateEmployeeImpl updateEmployee;
|
||||
|
||||
|
||||
@Nested
|
||||
class personalEmployeeUpdateResultTest {
|
||||
@Test
|
||||
void personalEmployeeUpdateResult_正常系_個人情報更新結果画面表示_パスワードが両方あり_メールアドレス重複無し() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.NORMAL_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", EmployeeEnum.NORMAL_EMPLOYEE.getPassword())
|
||||
)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_PERSONAL_RESULT_HTML));
|
||||
}
|
||||
|
||||
@Test
|
||||
void personalEmployeeUpdateResult_正常系_個人情報更新結果画面表示_パスワードが両方無し_メールアドレス重複無し() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress())
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", "")
|
||||
)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_PERSONAL_RESULT_HTML));
|
||||
}
|
||||
|
||||
@Test
|
||||
void personalEmployeeUpdateResult_異常系_個人情報更新結果画面表示_パスワードが両方あり_メールアドレス重複有り() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()));
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress())
|
||||
.param("password", EmployeeEnum.NORMAL_EMPLOYEE.getPassword())
|
||||
.param("passwordConfirm", EmployeeEnum.NORMAL_EMPLOYEE.getPassword())
|
||||
)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML));
|
||||
}
|
||||
|
||||
@Test
|
||||
void personalEmployeeUpdateResult_異常系_個人情報更新結果画面表示_パスワードが片方無し1_メールアドレス重複無し() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress())
|
||||
.param("password", "password")
|
||||
.param("passwordConfirm", "")
|
||||
)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML));
|
||||
}
|
||||
|
||||
@Test
|
||||
void personalEmployeeUpdateResult_異常系_個人情報更新結果画面表示_パスワードが片方無し2_メールアドレス重複無し() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee())
|
||||
.param("knEmployee", EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee())
|
||||
.param("mailAddress", EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress())
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", "password")
|
||||
)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML));
|
||||
}
|
||||
|
||||
@Test
|
||||
void personalEmployeeUpdateResult_異常系_個人情報更新結果画面表示_必須情報無し() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
session.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
).createLoginUser()
|
||||
));
|
||||
|
||||
when(searchEmployee.searchEmployee(any()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
doNothing().when(updateEmployee).updateEmployee(any(), any());
|
||||
|
||||
when(searchEmployee.searchLoginUser(any()))
|
||||
.thenReturn(new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT)
|
||||
.session(session)
|
||||
.param("idEmployee", String.valueOf(EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee()))
|
||||
.param("nmEmployee", "")
|
||||
.param("knEmployee", "")
|
||||
.param("mailAddress", "")
|
||||
.param("password", "")
|
||||
.param("passwordConfirm", "")
|
||||
)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(PageReturnAttributeKeyword.MESSAGE_ERROR))
|
||||
.andExpect(view().name(TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML));
|
||||
}
|
||||
}
|
||||
}
|
||||
2
src/test/resources/application-test.properties
Normal file
2
src/test/resources/application-test.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
# \u30C6\u30B9\u30C8\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u7528\u306E\u30D7\u30ED\u30D1\u30C6\u30A3
|
||||
aop.enabled=false
|
||||
Reference in New Issue
Block a user