woowacourse-teams / 2020-14f-guys Goto Github PK
View Code? Open in Web Editor NEW오프라인 스터디, 소모임의 목표 달성을 도와주는 동기부여 서비스 🚴♂️
Home Page: https://peloton.ga
License: MIT License
오프라인 스터디, 소모임의 목표 달성을 도와주는 동기부여 서비스 🚴♂️
Home Page: https://peloton.ga
License: MIT License
@SpringBootTest
class MemberRepositoryTest {
@Autowired
private MemberRepository memberRepository;
@DisplayName("주어진 Member 객체가 DB에 저장이 잘 되는지 확인")
@Test
void saveMember() {
final Member member = Member.builder()
.name("김범준")
.cash(new Cash(new BigDecimal(1)))
.email("[email protected]")
.role(Role.MEMBER)
.build();
final Member persisted = memberRepository.save(member);
assertAll(
() -> assertThat(persisted.getId()).isNotNull(),
() -> assertThat(persisted.getCash()).isEqualTo(new Cash(new BigDecimal(1))),
() -> assertThat(persisted.getName()).isEqualTo("김범준"),
() -> assertThat(persisted.getEmail()).isEqualTo("[email protected]"),
() -> assertThat(persisted.getRole()).isEqualTo(Role.MEMBER),
() -> assertThat(persisted.getCreatedAt()).isNotNull(),
() -> assertThat(persisted.getUpdatedAt()).isNotNull()
);
}
}
위 테스트는 모든 필드를 갖는 Member
객체를 만들고 repository.save()
를 통해 도메인-스키마 간 불일치 발생 또는 에러를 확인하는 테스트입니다.
현재는 도메인-스키마의 일치가 되는지 안되는지 확인할 방법이 없습니다. 또, 테스트 커버리지도 0%에 가깝기 때문에 후에 commit 할 때, 테스트 커버리지 80% 이상 원칙을 지키기 위해서라도 기본적인 Save 테스트는 있으면 좋다는 생각이 들었습니다.
하지만 각자 기능을 작성할 때, 그때 그때 각 기능 별로 테스트를 작성하면 된다고 생각할 수도 있기 때문에 간단하게 찬반 의견 정도 남겨주시면 감사하겠습니다 :)
아, 그리고 Assignees는 랜덤으로 정하는 게 좋을 것 같아요!
라이더별로 성취율을 계산하는 기능
성취율에 따라 금액을 분배하는 기능(수수료 포함)
Github 상에서 Action 수행 전, 후 자동으로 Script로 설정한 기능들이 수행됨
해당 내용을 학습하여 적용한다면, 빌드와 배포에 도움이 될 것으로 판단됩니다.
담당을 결정하는 방식은 사다리타기와 같이 랜덤하게 결정한다.
(원하는 사람이 가져가면 분배가 적절하지 않을 것 같기 때문에)
private
으로 감추고 Builder만 사용 가능id
필드에 Wither(@With
)가 없어야함BaseEntity
의 필드를 포함한 @PersistenceConstructor
를 따로 만들어야함(Spring Data JDBC에서 인스턴스를 생성할 때 사용)BaseEntity
에는 반드시 @NoArgConstructor
가 존재해야함// Entity.java
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
@EqualsAndHashCode(of = "id", callSuper = false)
@Getter
public class Entity extends BaseEntity {
@Id
private final Long id;
@NotBlank
private final String name;
@PersistenceConstructor
private Entity(Long id, String name, LocalDateTime createdAt, LocalDateTime updatedAt) {
super(createdAt, updatedAt);
this.id = id;
this.name = name;
}
}
// BaseEntity.java
@AllArgsConstructor
@NoArgsConstructor
@Getter
public abstract class BaseEntity {
@CreatedDate
private LocalDateTime createdAt;
@LastModifiedDate
private LocalDateTime updatedAt;
}
@CreatedDate
, @LastModifiedDate
가 직접 필드에 들어옴id
필드에 Wither(@With
)가 필요함// Entity.java
@Builder
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@Getter
@EqualsAndHashCode(of = "id")
public class Entity {
@Id
@With(AccessLevel.PACKAGE)
private final Long id;
@NotBlank
private final String name;
@CreatedDate
private LocalDateTime createdAt;
@LastModifiedDate
private LocalDateTime updatedAt;
}
@PersistenceConstructor
를 작성하는 코드량 vs createdAt
, updatedAt
필드를 작성하는 코드량@PersistenceConstructor
vs 하나의 생성자 + Wither (링크를 참조하면 Spring Data JDBC는 후자를 선호)의견 달아주시면 감사하겠습니다!
이 부분은 모두가 알아야 하는 부분이지만, 조금 더 잘 아는 사람이 알려주는 방식이 좋아보임.
그래서 특정 한명 혹은 두명이 추가로 학습하고, 우리 프로젝트에서 이 부분은 rest 하지 않은데? 라고 제언할 수 있으면 좋을 것 같음.
#54 미션을 생성하는 기능을 진행하다 보니
Mission
필드의 MissionInstruction
을 생성하는 기능이 필요 할 것 같습니다.
일반적으로 카카오 로그인에 대해 떠올리면
이를 어플에서 가능하게 하려면 Kakao SDK를 다운받아서 사용해야하는데
Expo는 외부 네이티브 모듈을 지원하지 않기 때문에 위 프로세스가 불가능합니다. 링크 참고
어떤 방법이 좋을지 의논해봐야할 것 같네요 😄
다른 해결 방법이 있다면 답글 달아주시면 감사하겠습니다 🙇
final MissionCertificationReport persist = missionCertificationReportRepository.save(
missionCertificationReport);
우리 포맷팅 컨벤션 기준 라인 수를 넘어가서 save() 만 사용하도 두 줄이 됩니다.
네이밍을 다시 생각해볼 만한 것 같아요!
create table if not exists RIDER
(
...
foreign key (MEMBER_ID) references MEMBER (ID),
foreign key (RACE_ID) references RACE (ID)
);
@DisplayName("Rider 엔티티가 저장되는지 확인")
@Test
void save() {
Rider rider = Rider.builder()
.memberId(AggregateReference.to(1L))
.raceId(AggregateReference.to(1L))
.build();
Rider persisted = riderRepository.save(rider);
assertThat(persisted.getId()).isNotNull();
}
위와 같이 테스트 코드 작성 시, 현재 DB에 Id가 1인 Member
와 Race
가 존재하지 않아서 데이터 무결성 예외가 발생합니다. 테스트 코드를 통과시키려면 각각 Id가 1인 Member
와 Race
객체를 생성하고 DB에 저장한 뒤, 위 테스트를 다시 진행해야합니다.
Aggregate Root 간의 관계를 끊어서 테스트를 쉽게 한다.
Spring Data JDBC 소개 영상에서 나온 장점인만큼 스키마에 외래키를 등록하는 문제를 다시 한 번 생각해보면 좋을 것 같습니다 😄
괄호 포함 시 에러
값 객체에서 사용되는 모든 코드를 포함하고 있어 고려해볼만 하다고 판단됩니다.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.