Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: YSL-12 출근 타이머 등록 기능 추가 #11

Merged
merged 17 commits into from
Jan 13, 2024
Merged

Conversation

zinzoddari
Copy link
Member

최초 타이머 저장을 요청할 경우, 조회할 수 있는 URL이 반환됩니다.

@zinzoddari zinzoddari added the ✨ feature 새로운 요구사항을 반영한 기능을 개발 label Jan 4, 2024
@JHwan96
Copy link

JHwan96 commented Jan 4, 2024

오오오 잘 참고하겠습니다

@zinzoddari zinzoddari changed the title feat: YSL-12 출근 타이머 등록 기능 추가 DRAFT: feat: YSL-12 출근 타이머 등록 기능 추가 Jan 7, 2024
@zinzoddari zinzoddari changed the title DRAFT: feat: YSL-12 출근 타이머 등록 기능 추가 feat: YSL-12 출근 타이머 등록 기능 추가 Jan 8, 2024
Comment on lines +60 to +71
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
WorkTimer workTimer = (WorkTimer) o;
return Objects.equals(id, workTimer.id) && Objects.equals(checkIn, workTimer.checkIn) && Objects.equals(checkOut, workTimer.checkOut) && Objects.equals(code, workTimer.code);
}

@Override
public int hashCode() {
return Objects.hash(id, checkIn, checkOut, code);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain 부분에서 메소드를 만드는 것은 update 기능을 만들 때 사용한다고 생각했었는데 equals와 hashCode를 보고 값을 비교하거나 암호와 하는 메소드도 추가할 수 있다는 것을 알게 되었습니다.

import org.idiot.yesslave.worktimer.domain.WorkTimer;
import org.springframework.data.jpa.repository.JpaRepository;

public interface WorkTimerRepository extends JpaRepository<WorkTimer, Long>, WorkTimerCustomRepository {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WorkTimerCustomRepository를 따로 빼두신 이유가 나중에 관리하기 편함인지 궁금합니다:)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JpaRepository를 상속받은 WorkTimerRepository를 implements 해서 구현하려고 하면, JpaRepository의 메소드들을 다 재정의를 해주어야 하기 때문에 .🥹. 자연스럽게 CustomRepository로 분리하게 되어씁니다 👍🏻

Copy link
Member

@beng9re beng9re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

�일단 승인합니다.
한번 봐줬으면 하는 부분 코멘트 달아드렸어요


@PostMapping
public ResponseEntity<Void> timerCreate() {
Long response = workTimerService.registerTimer(LocalDateTime.now(), new RandomCodeGenerator());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RandomCodeGenerator.java 싱글톤으로 생성했지만 실제 사용은 객체를 만들어서 사용하는거 같네요 🥲


@Entity
@Getter
@AllArgsConstructor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AllArgsConstructor 쓰신 이유가 궁금합니다

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

비즈니스 코드를 작성할떄는 크게 작성할 일이 없다만, 테스트 코드 작성시에 값을 할당해주기 위해 사용하고 있습니다.
혹시 다른 방법이 있을까요?

Comment on lines 30 to 32
@AutoConfigureMockMvc
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
Copy link

@midcondria midcondria Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컨트롤러 테스트에서 Mocking 을 사용하는데 @SpringBootTest 를 사용하신 이유가 있는지 궁금합니다.
제가 알기론 @SpringBootTest 는 기본적으로 모든 빈을 탐색하고 등록한다고 알고 있어서요.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 mocking하는데에 있어서 webEnvironment = SpringBootTest.WebEnvironment.MOCK를 명시해주면 mocking 환경을 제공해준다고 생각을 했는데, 현우님이 주신 코멘트로 인해 찾아보니 @SpringBootTest 자체가 기본 환경이 MOCK이라고 하네요. ((충격))

새로이 배우게 되었습니다.

지금 새롭게 만드는 feature에서는 @WebMvcTest로 구현 해보고, 테스트가 원할히 된다면 해당 코드도 수정을 해 보아야겠습니다

@zinzoddari zinzoddari merged commit 0e3b63e into develop Jan 13, 2024
@zinzoddari zinzoddari deleted the YSL-12 branch January 13, 2024 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature 새로운 요구사항을 반영한 기능을 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants