Skip to content

Commit

Permalink
[refactor] #215 Entity 삭제 방지, 통합 테스트 코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
HYG committed Feb 15, 2024
1 parent 7fc157e commit a5c78fa
Show file tree
Hide file tree
Showing 15 changed files with 2,010 additions and 425 deletions.
37 changes: 24 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

ext{
snippetDir = file('build/generated-snippets') //snippets 파일을 저장할 디렉토리 생성
snippetsDir = file('build/generated-snippets') // (5)
}

group = 'com'
Expand All @@ -19,6 +19,7 @@ java {
}

configurations {
asciidoctorExt // (2)
compileOnly {
extendsFrom annotationProcessor
}
Expand Down Expand Up @@ -55,11 +56,14 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
//testImplementation 'org.springframework.kafka:spring-kafka-test'
testImplementation group: 'org.springframework.restdocs', name: 'spring-restdocs-mockmvc'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor' // (3)
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' // (4)

}

tasks.named('test') {
useJUnitPlatform()
outputs.dir snippetsDir // (6)
}
jacoco {
toolVersion = "0.8.8"
Expand All @@ -83,15 +87,22 @@ sonarqube {
property "sonar.encoding", "UTF-8"
}
}
asciidoctor{ //asciidoctor 설정 task
inputs.dir snippetDir //snippets 디렉토리를 입력으로 함
dependsOn test // test task를 의존하도록 하여, 문서 생성 전에 test를 수행하도록 함
asciidoctor {
configurations 'asciidoctorExt' // (7)
baseDirFollowsSourceFile() // (8)
inputs.dir snippetsDir // (9)
dependsOn test // (10)
}
asciidoctor.doFirst {
delete file('src/main/resources/static/docs') // (11)
}
task copyDocument(type: Copy) { // (12)
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}

bootJar{ //springboot를 이용한 jar 파일 생성 시 필요한 설정 task
dependsOn asciidoctor //asciidoctor 를 의존하도록 하여, bootJar 생성 전에 asciidoctor task를 수행하도록 함
// (jar 파일 생성 시, 문서 생성을 보장 함)
from("build/docs/asciidoc"){ //문서 생성 시, Jar 파일 내 static/docs 에도 복사되도록 함
into 'BOOT-INF/classes/static/docs'
}
}

build {
dependsOn copyDocument
}

10 changes: 5 additions & 5 deletions src/docs/asciidoc/index.docs → src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ifndef::snippets[]
:snippets: ./build/generated-snippets
endif::[]

=== Request Code
include::http-request.adoc[]
=== Response Code
include::http-response.adoc[]
==== Request Code
include::{snippets}/join/http-request.adoc[]

==== Response Code
include::{snippets}/join/http-response.adoc[]
1 change: 0 additions & 1 deletion src/main/java/com/dmarket/controller/AdminController.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ public ResponseEntity<CMResDto<Page<InquiryResDto.InquiryListResDto>>> getInquir
}
}
Page<InquiryResDto.InquiryListResDto> mappedInquiries = adminService.getAllInquiriesByType(inquiryType, pageNo);

CMResDto<Page<InquiryResDto.InquiryListResDto>> response = CMResDto.successDataRes(mappedInquiries);
return new ResponseEntity<>(response, HttpStatus.OK);
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/dmarket/domain/product/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public class Product {
@Column(nullable = true)
private LocalDateTime productCreatedDate;

@Column(nullable = false, columnDefinition = "boolean default true")
private Boolean productSaleState;


public void updateRating(Float newRating) {
this.productRating = newRating;
Expand All @@ -73,6 +70,5 @@ public Product(Long categoryId, String productBrand, String productName, Integer
this.productDescription = productDescription;
this.productRating = (float) 0;
this.productCreatedDate = LocalDateTime.now().truncatedTo(ChronoUnit.MICROS);
this.productSaleState = true;
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/dmarket/dto/request/UserReqDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public static class UserAddress {
}

@Data
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class Join {

@NotBlank
Expand Down Expand Up @@ -75,6 +78,7 @@ public static class ChangeRole {
}

@Data
@AllArgsConstructor
public static class Emails {
private String userEmail;
private String code;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/dmarket/service/AdminService.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ public void updateReturnState(Long returnId, String returnState) {
refundRepository.save(refund);
}
ReturnState state = ReturnState.fromLabel(returnState);
returnEntity.updateReturnState(state);
System.out.println("returnState = " + state);


// OrderDetailRepository를 통해 orderId를 가져옴.
OrderDetail orderDetail = orderDetailRepository.findByOrderDetailId(returnEntity.getOrderDetailId());
Expand All @@ -606,7 +607,7 @@ public void updateReturnState(Long returnId, String returnState) {
"주문 아이디와 일치하는 사용자 아이디가 없음, order ID: " + orderDetail.getOrderId()));
// 상품명 가져오기
String productName = productRepository.findProductName(orderDetail.getProductId());

returnEntity.updateReturnState(state);
// 반품 상태가 변경된 후 알림 전송
publisher.publishEvent(SendNotificationEvent.of("return", userId,
productName + "(이)가 " + returnState + " 상태입니다.",
Expand Down
Loading

0 comments on commit a5c78fa

Please sign in to comment.