From 4159644b3402dd337a918129e8b1d47535b25bf8 Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Thu, 10 Jun 2021 18:56:23 +0900 Subject: [PATCH 01/15] chore : Add test dependency and h2 properties(#14) --- BE/build.gradle | 1 + BE/src/main/resources/application.properties | 23 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/BE/build.gradle b/BE/build.gradle index c7d6b5c0a..a0e76da35 100644 --- a/BE/build.gradle +++ b/BE/build.gradle @@ -22,6 +22,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.auth0:java-jwt:3.16.0' + implementation 'junit:junit:4.13.1' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'com.h2database:h2' diff --git a/BE/src/main/resources/application.properties b/BE/src/main/resources/application.properties index b135104dd..65949eb29 100644 --- a/BE/src/main/resources/application.properties +++ b/BE/src/main/resources/application.properties @@ -1 +1,24 @@ spring.profiles.include=secret + +# 실행 쿼리 보기 설정 +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.format_sql=true + +# DB DB connection 설정 +# DB_CLOSE_ON_EXIT : 인메모리 DB의 종료마저도 스프링 부트가 관리. +spring.datasource.url=jdbc:h2:mem://localhost/~/issuetracker;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= + +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect + +# 서버 시작 시점 db table drop후 다시 생성 +spring.jpa.hibernate.ddl-auto=create-drop + +# h2 db console 접근 설정 +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console + +#logging level +logging.level.com.codesquad.issuetracker.milestone=DEBUG From 973a378e79454378cde5b531331dfd35c50b296d Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Thu, 10 Jun 2021 19:00:14 +0900 Subject: [PATCH 02/15] feat : Add Milestone domain(#14) --- .../milestone/domain/Milestone.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java new file mode 100644 index 000000000..5d5ae08c8 --- /dev/null +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java @@ -0,0 +1,46 @@ +package com.codesquad.issuetracker.milestone.domain; + +import com.codesquad.issuetracker.milestone.dto.MilestoneRequestDto; +import lombok.*; +import org.hibernate.annotations.GenericGenerator; + +import javax.persistence.*; +import java.time.LocalDate; +import java.util.UUID; + +@Entity +@NoArgsConstructor +@RequiredArgsConstructor +@Getter +@ToString +public class Milestone { + + @Id + @GeneratedValue( generator = "uuid2" ) + @GenericGenerator( name = "uuid2", strategy = "uuid2" ) + @Column( name = "MILESTONE_ID", columnDefinition = "BINARY(16)" ) + private UUID id; + + @NonNull + @Column(name = "MILESTONE_TITLE", unique = true, length = 255) + private String title; + + @NonNull + @Lob + @Column(name = "DESCRIPTION") + private String description; + + @NonNull + @Column(name = "DUE_DATE") + private LocalDate dueDate; + + public static Milestone create(String title, String description, LocalDate dueDate) { + return new Milestone(title, description, dueDate); + } + + public void update(MilestoneRequestDto milestoneRequest) { + this.title = milestoneRequest.getTitle(); + this.description = milestoneRequest.getDescription(); + this.dueDate = milestoneRequest.getDueDate(); + } +} From 5a3d0da2f2034b538e6daf9eaeb26ac5c0e4a47f Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Thu, 10 Jun 2021 19:01:16 +0900 Subject: [PATCH 03/15] feat : Add MilestoneRepository(#14) --- .../milestone/infra/MilestoneRepository.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 BE/src/main/java/com/codesquad/issuetracker/milestone/infra/MilestoneRepository.java diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/infra/MilestoneRepository.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/infra/MilestoneRepository.java new file mode 100644 index 000000000..0fc1d2142 --- /dev/null +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/infra/MilestoneRepository.java @@ -0,0 +1,12 @@ +package com.codesquad.issuetracker.milestone.infra; + +import com.codesquad.issuetracker.milestone.domain.Milestone; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; +import java.util.UUID; + +public interface MilestoneRepository extends CrudRepository { + @Override + List findAll(); +} From fb635dc74b3a30505cca11a3c1d748f296a19f0a Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Thu, 10 Jun 2021 19:02:14 +0900 Subject: [PATCH 04/15] feat : Add H2 DataBase connection(#14) --- .../milestone/domain/MilestoneTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 BE/src/test/java/com/codesquad/issuetracker/milestone/domain/MilestoneTest.java diff --git a/BE/src/test/java/com/codesquad/issuetracker/milestone/domain/MilestoneTest.java b/BE/src/test/java/com/codesquad/issuetracker/milestone/domain/MilestoneTest.java new file mode 100644 index 000000000..499e67f93 --- /dev/null +++ b/BE/src/test/java/com/codesquad/issuetracker/milestone/domain/MilestoneTest.java @@ -0,0 +1,52 @@ +package com.codesquad.issuetracker.milestone.domain; + + +import com.codesquad.issuetracker.milestone.infra.MilestoneRepository; +import org.junit.After; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.swing.text.html.parser.Entity; +import java.time.LocalDate; +import java.util.List; + +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; + +@DataJpaTest +public class MilestoneTest { + + @Autowired + MilestoneRepository milestoneRepository; + + @After + public void cleanup() { + milestoneRepository.deleteAll(); + + } + @Test + @DisplayName("milestone이 추가되었는지를 확인한다.") + public void createMilestone() { + String name = "제목"; + String description = "세부설명"; + + Milestone milestone = Milestone + .create("제목", "세부설명", LocalDate.now()); + + milestoneRepository.save(milestone); + + List milestoneList = milestoneRepository.findAll(); + + Milestone milestoneInDb = milestoneList.get(0); + + assertThat(milestoneInDb.getTitle()).isEqualTo(name); + assertThat(milestoneInDb.getDescription()).isEqualTo(description); + } +} From 2a46750f726ce3acea73da4ddeef07fa87643fbd Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Thu, 10 Jun 2021 19:03:15 +0900 Subject: [PATCH 05/15] feat : Add dto and wrapper(#14) --- .../milestone/dto/MilestoneRequestDto.java | 34 +++++++++++++ .../milestone/dto/MilestoneResponseDto.java | 50 +++++++++++++++++++ .../milestone/dto/MilestoneWrapper.java | 17 +++++++ .../milestone/dto/MilestonesWrapper.java | 19 +++++++ 4 files changed, 120 insertions(+) create mode 100644 BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneRequestDto.java create mode 100644 BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneResponseDto.java create mode 100644 BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneWrapper.java create mode 100644 BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestonesWrapper.java diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneRequestDto.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneRequestDto.java new file mode 100644 index 000000000..4c7550a81 --- /dev/null +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneRequestDto.java @@ -0,0 +1,34 @@ +package com.codesquad.issuetracker.milestone.dto; + +import com.codesquad.issuetracker.milestone.domain.Milestone; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.beans.ConstructorProperties; +import java.time.LocalDate; + +@Getter +@NoArgsConstructor +@ToString +public class MilestoneRequestDto { + + private String title; + + private String description; + + private LocalDate dueDate; + + @ConstructorProperties({"title", "description", "dueDate"}) + public MilestoneRequestDto(String title, String description, + @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate dueDate) { + this.title = title; + this.description = description; + this.dueDate = dueDate; + } + + public Milestone toEntity() { + return Milestone.create(title, description, dueDate); + } +} diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneResponseDto.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneResponseDto.java new file mode 100644 index 000000000..ef0e06342 --- /dev/null +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneResponseDto.java @@ -0,0 +1,50 @@ +package com.codesquad.issuetracker.milestone.dto; + +import com.codesquad.issuetracker.milestone.domain.Milestone; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDate; +import java.util.Objects; +import java.util.UUID; + +@ToString +@Getter +public class MilestoneResponseDto { + + private UUID id; + + private String title; + + private String description; + + private LocalDate dueDate; + + public MilestoneResponseDto(UUID id, String title, String description, LocalDate dueDate) { + this.id = id; + this.title = title; + this.description = description; + this.dueDate = dueDate; + } + + public static MilestoneResponseDto fromEntity (Milestone entity) { + return new MilestoneResponseDto(entity.getId(), + entity.getTitle(), + entity.getDescription(), + entity.getDueDate()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof MilestoneResponseDto)) return false; + MilestoneResponseDto that = (MilestoneResponseDto) o; + return Objects.equals(id, that.id) && Objects.equals(title, that.title) && + Objects.equals(description, that.description) && Objects.equals(dueDate, that.dueDate); + } + + @Override + public int hashCode() { + return Objects.hash(id, title, description, dueDate); + } +} diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneWrapper.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneWrapper.java new file mode 100644 index 000000000..aa86d9a83 --- /dev/null +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneWrapper.java @@ -0,0 +1,17 @@ +package com.codesquad.issuetracker.milestone.dto; + +import lombok.Getter; + +@Getter +public class MilestoneWrapper { + + private MilestoneResponseDto milestoneResponseDto; + + private MilestoneWrapper(MilestoneResponseDto milestoneResponseDto) { + this.milestoneResponseDto = milestoneResponseDto; + } + + public static MilestoneWrapper create(MilestoneResponseDto milestoneResponseDto) { + return new MilestoneWrapper(milestoneResponseDto); + } +} diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestonesWrapper.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestonesWrapper.java new file mode 100644 index 000000000..cc10c4341 --- /dev/null +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestonesWrapper.java @@ -0,0 +1,19 @@ +package com.codesquad.issuetracker.milestone.dto; + +import lombok.Getter; + +import java.util.List; + +@Getter +public class MilestonesWrapper { + + private List milestoneResponseDtoList; + + private MilestonesWrapper(List milestoneResponseDtoList) { + this.milestoneResponseDtoList = milestoneResponseDtoList; + } + + public static MilestonesWrapper create(List milestoneResponseDtoList) { + return new MilestonesWrapper(milestoneResponseDtoList); + } +} From 75df0e8f793b298c30f67e63c1df9640166e653d Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Thu, 10 Jun 2021 19:04:03 +0900 Subject: [PATCH 06/15] feat : Add milestone CRUD(#14) --- .../controller/MilestoneController.java | 49 +++++++++++++++ .../milestone/service/MilestoneService.java | 61 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java create mode 100644 BE/src/main/java/com/codesquad/issuetracker/milestone/service/MilestoneService.java diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java new file mode 100644 index 000000000..8abf1eaf0 --- /dev/null +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java @@ -0,0 +1,49 @@ +package com.codesquad.issuetracker.milestone.controller; + + +import com.codesquad.issuetracker.milestone.dto.MilestoneRequestDto; +import com.codesquad.issuetracker.milestone.dto.MilestoneWrapper; +import com.codesquad.issuetracker.milestone.dto.MilestonesWrapper; +import com.codesquad.issuetracker.milestone.service.MilestoneService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; + +import java.util.UUID; + +@RestController +@RequestMapping("/api/milestones") +public class MilestoneController { + + private final Logger logger = LoggerFactory.getLogger(MilestoneController.class); + + private final MilestoneService milestoneService; + + public MilestoneController(MilestoneService milestoneService) { + this.milestoneService = milestoneService; + } + + @GetMapping + public MilestonesWrapper readMilestones() { + return milestoneService.readAllMilestones(); + } + + @PostMapping + public MilestoneWrapper createMilestone(@RequestBody MilestoneRequestDto milestoneRequestDto) { + logger.debug("{}", milestoneRequestDto); + return milestoneService.createMilestone(milestoneRequestDto); + } + + @PutMapping("/{id}") + public MilestoneWrapper updateMilestone(@PathVariable UUID id, @RequestBody MilestoneRequestDto milestoneRequest) { + logger.debug("{}", id); + return milestoneService.updateMilestone(id, milestoneRequest); + } + + @DeleteMapping("/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void deleteMilestone(@PathVariable UUID id) { + milestoneService.deleteMilestone(id); + } +} diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/service/MilestoneService.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/service/MilestoneService.java new file mode 100644 index 000000000..988dbde1b --- /dev/null +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/service/MilestoneService.java @@ -0,0 +1,61 @@ +package com.codesquad.issuetracker.milestone.service; + +import com.codesquad.issuetracker.milestone.domain.Milestone; +import com.codesquad.issuetracker.milestone.dto.MilestoneRequestDto; +import com.codesquad.issuetracker.milestone.dto.MilestoneResponseDto; +import com.codesquad.issuetracker.milestone.dto.MilestoneWrapper; +import com.codesquad.issuetracker.milestone.dto.MilestonesWrapper; +import com.codesquad.issuetracker.milestone.infra.MilestoneRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +@Service +public class MilestoneService { + + private final Logger logger = LoggerFactory.getLogger(MilestoneService.class); + + private final MilestoneRepository milestoneRepository; + + public MilestoneService(MilestoneRepository milestoneRepository) { + this.milestoneRepository = milestoneRepository; + } + + public MilestoneWrapper createMilestone(MilestoneRequestDto milestoneRequest) { + Milestone milestone = milestoneRepository.save(milestoneRequest.toEntity()); + MilestoneResponseDto milestoneResponseDto = MilestoneResponseDto.fromEntity(milestone); + + logger.debug("{}", milestone); + + return MilestoneWrapper.create(milestoneResponseDto); + } + + public MilestonesWrapper readAllMilestones() { + List milestoneList = milestoneRepository.findAll(); + List milestoneResponseDtoList = milestoneList.stream() + .map(milestone -> MilestoneResponseDto.fromEntity(milestone)) + .collect(Collectors.toList()); + + return MilestonesWrapper.create(milestoneResponseDtoList); + } + + public MilestoneWrapper updateMilestone(UUID id, MilestoneRequestDto milestoneRequest) { + Milestone milestone = milestoneRepository.findById(id).orElseThrow(RuntimeException::new); + milestone.update(milestoneRequest); + Milestone updatedMilestone = milestoneRepository.save(milestone); + + logger.debug("{}", milestone); + + MilestoneResponseDto milestoneResponseDto = MilestoneResponseDto.fromEntity(updatedMilestone); + + return MilestoneWrapper.create(milestoneResponseDto); + } + + public void deleteMilestone(UUID id) { + milestoneRepository.deleteById(id); + } +} From 382be80d42241425d01cf0c568bc093135cb1aab Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:05:50 +0900 Subject: [PATCH 07/15] feat : Correct detail of field option (#14) - Add nullable false in title - Add nullable false in description - Remove @NonNull in dueDate - Add access modifier in NoArgsConstructor annotation --- .../issuetracker/milestone/domain/Milestone.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java index 5d5ae08c8..459f3f1f5 100644 --- a/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java @@ -9,8 +9,7 @@ import java.util.UUID; @Entity -@NoArgsConstructor -@RequiredArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter @ToString public class Milestone { @@ -22,18 +21,23 @@ public class Milestone { private UUID id; @NonNull - @Column(name = "MILESTONE_TITLE", unique = true, length = 255) + @Column(name = "MILESTONE_TITLE", unique = true, nullable = false) private String title; @NonNull @Lob - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", nullable = false) private String description; - @NonNull @Column(name = "DUE_DATE") private LocalDate dueDate; + private Milestone(@NonNull String title, @NonNull String description, LocalDate dueDate) { + this.title = title; + this.description = description; + this.dueDate = dueDate; + } + public static Milestone create(String title, String description, LocalDate dueDate) { return new Milestone(title, description, dueDate); } From 84afe299cfd8994b4afa8f15e530d28a1f7a58be Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:12:29 +0900 Subject: [PATCH 08/15] feat : Correct details in MilestoneRequestDt(#14) - Add final keyword in field - Correct constructor to RequiredArgsConstructor annotation --- .../milestone/dto/MilestoneRequestDto.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneRequestDto.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneRequestDto.java index 4c7550a81..a821d46b4 100644 --- a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneRequestDto.java +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneRequestDto.java @@ -2,31 +2,21 @@ import com.codesquad.issuetracker.milestone.domain.Milestone; import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; -import java.beans.ConstructorProperties; import java.time.LocalDate; @Getter -@NoArgsConstructor +@RequiredArgsConstructor @ToString public class MilestoneRequestDto { - private String title; + private final String title; - private String description; + private final String description; - private LocalDate dueDate; - - @ConstructorProperties({"title", "description", "dueDate"}) - public MilestoneRequestDto(String title, String description, - @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate dueDate) { - this.title = title; - this.description = description; - this.dueDate = dueDate; - } + private final LocalDate dueDate; public Milestone toEntity() { return Milestone.create(title, description, dueDate); From a656237d24d92f89e3ec081ea835d117956877bf Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:15:05 +0900 Subject: [PATCH 09/15] style : Correct variable name(#14) - Correct MilestoneRequest to MilestoneRequestDto --- .../milestone/controller/MilestoneController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java index 8abf1eaf0..2a32a246a 100644 --- a/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java @@ -36,9 +36,9 @@ public MilestoneWrapper createMilestone(@RequestBody MilestoneRequestDto milesto } @PutMapping("/{id}") - public MilestoneWrapper updateMilestone(@PathVariable UUID id, @RequestBody MilestoneRequestDto milestoneRequest) { + public MilestoneWrapper updateMilestone(@PathVariable UUID id, @RequestBody MilestoneRequestDto milestoneRequestDto) { logger.debug("{}", id); - return milestoneService.updateMilestone(id, milestoneRequest); + return milestoneService.updateMilestone(id, milestoneRequestDto); } @DeleteMapping("/{id}") From df8eb42238ef54f0ac226bb5b15845c389328758 Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:18:03 +0900 Subject: [PATCH 10/15] refactor : Remove Junit implementation(#14) --- BE/build.gradle | 1 - .../issuetracker/milestone/domain/MilestoneTest.java | 12 +++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/BE/build.gradle b/BE/build.gradle index a0e76da35..c7d6b5c0a 100644 --- a/BE/build.gradle +++ b/BE/build.gradle @@ -22,7 +22,6 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.auth0:java-jwt:3.16.0' - implementation 'junit:junit:4.13.1' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'com.h2database:h2' diff --git a/BE/src/test/java/com/codesquad/issuetracker/milestone/domain/MilestoneTest.java b/BE/src/test/java/com/codesquad/issuetracker/milestone/domain/MilestoneTest.java index 499e67f93..1ad9f7150 100644 --- a/BE/src/test/java/com/codesquad/issuetracker/milestone/domain/MilestoneTest.java +++ b/BE/src/test/java/com/codesquad/issuetracker/milestone/domain/MilestoneTest.java @@ -2,19 +2,12 @@ import com.codesquad.issuetracker.milestone.infra.MilestoneRepository; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.swing.text.html.parser.Entity; import java.time.LocalDate; import java.util.List; @@ -26,11 +19,12 @@ public class MilestoneTest { @Autowired MilestoneRepository milestoneRepository; - @After + @AfterEach public void cleanup() { milestoneRepository.deleteAll(); } + @Test @DisplayName("milestone이 추가되었는지를 확인한다.") public void createMilestone() { From c85b0af88ffd058621a108dbe4b356a472cc8dc3 Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:21:40 +0900 Subject: [PATCH 11/15] refactor : Correct details in MilestoneResponse(#14) - Add final keyword in field - Correct AllArgsConstructor access modifier - Correct AllArgsConstructor to AllargsConstructor annotation --- .../milestone/dto/MilestoneResponseDto.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneResponseDto.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneResponseDto.java index ef0e06342..94f92016e 100644 --- a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneResponseDto.java +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestoneResponseDto.java @@ -1,6 +1,8 @@ package com.codesquad.issuetracker.milestone.dto; import com.codesquad.issuetracker.milestone.domain.Milestone; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.ToString; @@ -8,24 +10,18 @@ import java.util.Objects; import java.util.UUID; -@ToString @Getter +@ToString +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class MilestoneResponseDto { - private UUID id; + private final UUID id; - private String title; + private final String title; - private String description; + private final String description; - private LocalDate dueDate; - - public MilestoneResponseDto(UUID id, String title, String description, LocalDate dueDate) { - this.id = id; - this.title = title; - this.description = description; - this.dueDate = dueDate; - } + private final LocalDate dueDate; public static MilestoneResponseDto fromEntity (Milestone entity) { return new MilestoneResponseDto(entity.getId(), From 7567dbc520b88bf5e10cb69ac0679d6c602883c8 Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:24:04 +0900 Subject: [PATCH 12/15] refactor : Correct DB Column name(#14) --- .../codesquad/issuetracker/milestone/domain/Milestone.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java index 459f3f1f5..cd0bc86d9 100644 --- a/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/domain/Milestone.java @@ -26,10 +26,10 @@ public class Milestone { @NonNull @Lob - @Column(name = "DESCRIPTION", nullable = false) + @Column(name = "MILESTONE_DESCRIPTION", nullable = false) private String description; - @Column(name = "DUE_DATE") + @Column(name = "MILESTONE_DUE_DATE") private LocalDate dueDate; private Milestone(@NonNull String title, @NonNull String description, LocalDate dueDate) { From ca1842a683506833e42274de3178c7fce2c2f395 Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:25:03 +0900 Subject: [PATCH 13/15] refactor : Add AllArgsConstructor annotation(#14) --- .../issuetracker/milestone/dto/MilestonesWrapper.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestonesWrapper.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestonesWrapper.java index cc10c4341..72576aa65 100644 --- a/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestonesWrapper.java +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/dto/MilestonesWrapper.java @@ -1,18 +1,17 @@ package com.codesquad.issuetracker.milestone.dto; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; import lombok.Getter; import java.util.List; @Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class MilestonesWrapper { private List milestoneResponseDtoList; - private MilestonesWrapper(List milestoneResponseDtoList) { - this.milestoneResponseDtoList = milestoneResponseDtoList; - } - public static MilestonesWrapper create(List milestoneResponseDtoList) { return new MilestonesWrapper(milestoneResponseDtoList); } From db9b0b346588780b6947a639387b633a92470d68 Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:26:53 +0900 Subject: [PATCH 14/15] refactor : Correct logic to method reference(#14) --- .../issuetracker/milestone/service/MilestoneService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/service/MilestoneService.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/service/MilestoneService.java index 988dbde1b..4aca966de 100644 --- a/BE/src/main/java/com/codesquad/issuetracker/milestone/service/MilestoneService.java +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/service/MilestoneService.java @@ -37,7 +37,7 @@ public MilestoneWrapper createMilestone(MilestoneRequestDto milestoneRequest) { public MilestonesWrapper readAllMilestones() { List milestoneList = milestoneRepository.findAll(); List milestoneResponseDtoList = milestoneList.stream() - .map(milestone -> MilestoneResponseDto.fromEntity(milestone)) + .map(MilestoneResponseDto::fromEntity) .collect(Collectors.toList()); return MilestonesWrapper.create(milestoneResponseDtoList); From 9e0f86af3e048a98797f64a302a033656667a393 Mon Sep 17 00:00:00 2001 From: pbg0205 Date: Fri, 11 Jun 2021 12:34:19 +0900 Subject: [PATCH 15/15] refactor : Correct method name(#14) --- .../issuetracker/milestone/controller/MilestoneController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java b/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java index 2a32a246a..762c43111 100644 --- a/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java +++ b/BE/src/main/java/com/codesquad/issuetracker/milestone/controller/MilestoneController.java @@ -25,7 +25,7 @@ public MilestoneController(MilestoneService milestoneService) { } @GetMapping - public MilestonesWrapper readMilestones() { + public MilestonesWrapper readAllMilestones() { return milestoneService.readAllMilestones(); }