-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from readyvery/test
3월 25일 배포
- Loading branch information
Showing
8 changed files
with
152 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/com/readyvery/readyverydemo/domain/CeoMetaInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.readyvery.readyverydemo.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@Entity | ||
@Builder | ||
@Table(name = "INFOTAINMENT") | ||
@AllArgsConstructor | ||
@Slf4j | ||
public class CeoMetaInfo extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "ceo_meta_idx") | ||
private Long id; | ||
|
||
@Column(nullable = false, length = 45) | ||
private String storeName; | ||
|
||
@Column(nullable = false, length = 100) | ||
private String storeAddress; | ||
|
||
@Column(nullable = false, length = 45) | ||
private String registrationNumber; | ||
|
||
@Column(nullable = false, columnDefinition = "TEXT") | ||
private String businessLicenseFileName; | ||
|
||
@Column(nullable = false, columnDefinition = "TEXT") | ||
private String businessReportFileName; | ||
|
||
@Column(nullable = false, columnDefinition = "TEXT") | ||
private String identityCardFileName; | ||
|
||
@Column(nullable = false, columnDefinition = "TEXT") | ||
private String bankAccountFileName; | ||
|
||
// 입점신청 사장님 연관관계 매핑 | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "ceo_idx") | ||
private CeoInfo ceoInfo; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/readyvery/readyverydemo/src/point/DefaultPointPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.readyvery.readyverydemo.src.point; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class DefaultPointPolicy implements PointPolicy { | ||
private Double pointRate = 2.5; | ||
|
||
@Override | ||
public Long calculatePoint(Long price) { | ||
Double tmp = price * pointRate / 100 + 0.5; // 반올림 | ||
return tmp.longValue(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/readyvery/readyverydemo/src/point/PointPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.readyvery.readyverydemo.src.point; | ||
|
||
public interface PointPolicy { | ||
Long calculatePoint(Long price); | ||
} |
48 changes: 48 additions & 0 deletions
48
src/test/java/com/readyvery/readyverydemo/src/point/DefaultPointPolicyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.readyvery.readyverydemo.src.point; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class DefaultPointPolicyTest { | ||
@InjectMocks | ||
private DefaultPointPolicy defaultPointPolicy; | ||
|
||
@Test | ||
@DisplayName("작은 금액 테스트") | ||
void calculateSmallPoint() { | ||
// given | ||
Long amount = 1_050L; // 계산 금액 | ||
// when | ||
Long point = defaultPointPolicy.calculatePoint(amount); | ||
// then | ||
assertEquals(26L, point); | ||
} | ||
|
||
@Test | ||
@DisplayName("보통 금액 테스트") | ||
void calculateNomalPoint() { | ||
// given | ||
Long amount = 10_000L; // 계산 금액 | ||
// when | ||
Long point = defaultPointPolicy.calculatePoint(amount); | ||
// then | ||
assertEquals(250L, point); | ||
} | ||
|
||
@Test | ||
@DisplayName("큰 금액 테스트") | ||
void calculateBigPoint() { | ||
// given | ||
Long amount = 532_400L; // 계산 금액 | ||
// when | ||
Long point = defaultPointPolicy.calculatePoint(amount); | ||
// then | ||
assertEquals(13_310L, point); | ||
} | ||
} |