Skip to content

Commit

Permalink
Merge pull request #8 from Wonderful-Sigma/Feature/#2
Browse files Browse the repository at this point in the history
test
  • Loading branch information
JangBeomJun authored Jan 25, 2024
2 parents 016aa38 + 4e8cf2f commit 923fb5b
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public String newAccessToKen(@RequestHeader(value = "RefreshToken") String token

@PostMapping("/setFirebase/{memberId}")
public void setFirebaseToken(@PathVariable(value = "memberId") String memberId, @RequestBody SetFirebaseTokenRequest setFirebaseTokenRequest){
return;newTokenUseCase.setNewFirebaseToken(memberId,setFirebaseTokenRequest.firebaseToken());
newTokenUseCase.setNewFirebaseToken(memberId,setFirebaseTokenRequest.firebaseToken());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sigma.domain.account.model.Account;
import sigma.domain.account.model.value.*;
import sigma.domain.account.model.value.AccountNumber;
import sigma.domain.member.model.value.MemberId;

abstract class AccountConverter {

Expand All @@ -14,7 +14,7 @@ static Account toDomain(final AccountJPAEntity entity) {
return Account.builder()
.id(new AccountId(entity.getId()))
.accountInfo(new AccountInfo(entity.getNumber(), entity.getName()))
.holderId(new HolderId(entity.getHolderId()))
.holderId(new HolderId(new MemberId(entity.getHolderId())))
.balance(new Balance(entity.getBalance()))
.type(entity.getType())
.profile(new Profile(entity.getProfileImage()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AccountJPAEntity extends AbstractIdEntity {
private String name;

@NotNull
private Long holderId;
private String holderId;

@NotNull
private Long balance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class GroupMemberJPAEntity extends AbstractIdEntity {

@NotNull
private Long memberId;
private String memberId;
@NotNull
private Long accountId;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sigma.jpa.member;

import jakarta.persistence.EntityManager;
import jakarta.persistence.TypedQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import sigma.application.member.outport.MemberDBPort;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import sigma.domain.member.model.value.Role;
import sigma.jpa.common.entity.AbstractIdEntity;
import sigma.jpa.common.entity.AbstractTimeEntity;

@Entity
@Table(name = "tbl_member")
@Getter
@SuperBuilder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MemberJPAEntity /* extends AbstractIdEntity*/ {
public class MemberJPAEntity /* extends AbstractIdEntity*/ extends AbstractTimeEntity {

@jakarta.persistence.Id
private String Id;
private String id;

@NotNull
@Enumerated(value = EnumType.STRING)
Expand Down
2 changes: 1 addition & 1 deletion flick-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ dependencies {

implementation 'org.springframework.boot:spring-boot-starter-web'

runtimeOnly 'mysql:mysql-connector-java:8.0.33'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
}
2 changes: 1 addition & 1 deletion flick-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ server:

spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: org.mariadb.jdbc.Driver
url: ${DB_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sigma.domain.account.model.exception.NotAccountHolder;
import sigma.domain.account.model.value.*;
import sigma.domain.common.value.AbstractId;
import sigma.domain.member.model.value.MemberId;

import java.time.LocalDateTime;

Expand Down Expand Up @@ -32,7 +33,7 @@ public Account(final AccountId id, final AccountInfo accountInfo, final HolderId
this.modifiedAt = modifiedAt;
}

private void isHolder(final AbstractId memberId) {
private void isHolder(final MemberId memberId) {
if (!holderId.equals(memberId)) {
throw NotAccountHolder.EXCEPTION;
}
Expand All @@ -44,7 +45,7 @@ private void canAfford(final Long amount) {
}
}

public void send(final Long amount, final AbstractId memberId) {
public void send(final Long amount, final MemberId memberId) {
isHolder(memberId);
canAfford(amount);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package sigma.domain.account.model.value;

import sigma.domain.common.value.AbstractId;
import sigma.domain.member.model.value.MemberId;

public final class HolderId extends AbstractId {
public final class HolderId /*extends AbstractId */{
private final MemberId Id;

public HolderId(final Long id) {
super(id);
public HolderId(final MemberId id) {
this.Id = id;
}

public HolderId(final AbstractId id) {
super(id.getId());
public String getId() {
return Id.getId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AccountTest {
@BeforeEach
void setUp() {
final Balance balance = new Balance(1000L);
holderId = new HolderId(1L);
holderId = new HolderId(new MemberId("244fd654-891d-4cda-ba95-a96396811bc2"));
account = Account.builder()
.id(new AccountId(1L))
.accountInfo(new AccountInfo(2317L,"최수원의 계좌"))
Expand All @@ -37,21 +37,21 @@ void setUp() {
@Test
@DisplayName(value = "Holder 가 아닐 경우 송금 불가")
void HOLDER_가_아닐_경우_송금_불가() {
final MemberId memberId = new MemberId(3L);
final MemberId memberId = new MemberId("244fd654-891d-4cda-ba95-a96396811bc2");

assertThrows(NotAccountHolder.class, () -> account.send(500L, memberId));
}

@Test
@DisplayName(value = "잔액이 부족할 경우 송금 불가")
void 잔액이_부족할_경우_송금_불가() {
assertThrows(InsufficientBalance.class, () -> account.send(9999L, holderId));
assertThrows(InsufficientBalance.class, () -> account.send(9999L, new MemberId("244fd654-891d-4cda-ba95-a96396811bc2")));
}

@Test
@DisplayName(value = "송금 성공")
void 송금_성공() {
account.send(500L, holderId);
account.send(500L, new MemberId("244fd654-891d-4cda-ba95-a96396811bc2"));

assertEquals(500L, account.balance().getValue());
}
Expand Down

0 comments on commit 923fb5b

Please sign in to comment.