Skip to content

Commit

Permalink
Merge pull request #232 from PLADI-ALM/test/PDS-81-user-builder
Browse files Browse the repository at this point in the history
[PDS-81/hotfix] user builder id 추가
  • Loading branch information
chaerlo127 authored Nov 25, 2023
2 parents 95428fb + 0e9e954 commit c56a0f8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.example.pladialmserver.user.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class EmailPWReq {
@Schema(type = "String", description = "이메일", example = "[email protected]", required = true)
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/com/example/pladialmserver/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,18 @@ public class User extends BaseEntity {
private List<OfficeBooking> officeBookingList = new ArrayList<>();

@Builder
public User(String name, String email, String password, Department department, String phone, Role role, String fcmToken, String assets, Affiliation affiliation) {
public User(Long id, String name, String email, String password, Department department, String phone, Role role, String fcmToken, String assets, Affiliation affiliation) {
this.name = name;
this.email = email;
this.password = password;
this.department = department;
this.phone=phone;
this.phone = phone;
this.role = role;
this.fcmToken = fcmToken;
this.assets = assets;
this.affiliation = affiliation;
}

public User(Long userId, String name, String email, String password, String phone, String assets, Department department, Role role, Affiliation affiliation, String fcmToken) {
this.userId = userId;
this.name = name;
this.email = email;
this.password = password;
this.phone = phone;
this.assets = assets;
this.department = department;
this.role = role;
this.affiliation = affiliation;
this.fcmToken = fcmToken;
}

public static User toEntity(CreateUserReq req, Department department, Affiliation affiliation){
return User.builder()
.name(req.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ void findAvailableResourcesTest() {
}

private User createAndSaveUser(String name, String email, Department department, Affiliation affiliation) {
User user = new User(1L,
name,
email,
"password",
"010-1234-5678",
"testAssets",
department,Role.ADMIN,
affiliation);
User user = User.builder()
.id(1L)
.name("홍길동")
.email("[email protected]")
.password("asdf")
.phone("010-0000-0000")
.department(department)
.role(Role.ADMIN)
.assets("A12345")
.affiliation(affiliation)
.assets("1234545")
.build();
userRepository.save(user);
return user;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ public static CreateUserReq setUpCreateUserReq(String email, String pw){
}

public static User setUpUser(Long userId, Role role, Department department, Affiliation affiliation, String password){
return new User(
userId,
"홍길동",
"[email protected]",
password,
"010-0000-0000",
"A12345",
department,
role,
affiliation,
"1234545");
return User.builder()
.id(userId)
.name("홍길동")
.email("[email protected]")
.password("010-0000-0000")
.phone("010-0000-0000")
.department(department)
.role(role)
.assets("A12345")
.affiliation(affiliation)
.build();
}

public static Department setUpDepartment(){
Expand Down

0 comments on commit c56a0f8

Please sign in to comment.