Skip to content

Commit

Permalink
Sprint0/#219 (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
ozzing authored Apr 8, 2024
2 parents e7b681b + 648211a commit 9e4e6e4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/test/java/org/sopt/app/application/StampServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private Stamp getSavedStamp(Long missionId, Long requestUserId) {
final Long stampId = 1L;
final String contents = "savedContents";
final List<String> images = List.of("savedImage");
final LocalDateTime activityDate = LocalDateTime.of(2023, 1, 1, 0, 0, 0);
final String activityDate = "2024.04.08";

final Optional<Stamp> savedStamp = Optional.of(Stamp.builder()
.id(stampId)
Expand All @@ -219,7 +219,8 @@ private Stamp getSavedStamp(Long missionId, Long requestUserId) {
return savedStamp.get();
}

private StampInfo.Stamp editStamp(Stamp oldStamp, StampRequest.EditStampRequest editStampRequest, boolean isDeprecatedEditStampContents) {
private StampInfo.Stamp editStamp(Stamp oldStamp, StampRequest.EditStampRequest editStampRequest,
boolean isDeprecatedEditStampContents) {
if (!isDeprecatedEditStampContents && StringUtils.hasText(editStampRequest.getContents())) {
oldStamp.changeContents(editStampRequest.getContents());
}
Expand Down Expand Up @@ -278,7 +279,7 @@ void SUCCESS_editStampContents() {
final Long requestMissionId = anyLong();
final String requestContents = "requestContents";
final String requestImage = "requestImage";
final LocalDateTime requestActivityDate = LocalDateTime.now();
final String requestActivityDate = "2024.04.08";

StampRequest.EditStampRequest editStampRequest = new StampRequest.EditStampRequest();
editStampRequest.setContents(requestContents);
Expand All @@ -288,7 +289,7 @@ void SUCCESS_editStampContents() {

//when
Stamp oldStamp = getSavedStamp(requestMissionId, requestUserId);
editStamp(oldStamp, editStampRequest,false);
editStamp(oldStamp, editStampRequest, false);
StampInfo.Stamp result = stampService.editStampContents(editStampRequest, requestUserId);

//then
Expand All @@ -304,7 +305,8 @@ void SUCCESS_editStampContentsNoContents() {

final String requestBlankContents = "";
final String requestImage = "requestImage";
final LocalDateTime requestActivityDate = LocalDateTime.now();
final String requestActivityDate = "2024.04.08";

StampRequest.EditStampRequest editStampRequest = new StampRequest.EditStampRequest();
editStampRequest.setContents(requestBlankContents);
editStampRequest.setImage(requestImage);
Expand All @@ -328,7 +330,7 @@ void SUCCESS_editStampContentsNoImage() {
final Long requestMissionId = anyLong();
final String requestContents = "requestContents";
final String requestBlankImage = "";
final LocalDateTime requestActivityDate = LocalDateTime.now();
final String requestActivityDate = "2024.04.08";

StampRequest.EditStampRequest editStampRequest = new StampRequest.EditStampRequest();
editStampRequest.setContents(requestContents);
Expand Down Expand Up @@ -449,7 +451,8 @@ void FAIL_checkDuplicateStamp() {
final Long anyMissionId = anyLong();

//when
Mockito.when(stampRepository.findByUserIdAndMissionId(anyUserId, anyMissionId)).thenReturn(Optional.of(new Stamp()));
Mockito.when(stampRepository.findByUserIdAndMissionId(anyUserId, anyMissionId))
.thenReturn(Optional.of(new Stamp()));

//then
Assertions.assertThrows(BadRequestException.class, () -> {
Expand Down

0 comments on commit 9e4e6e4

Please sign in to comment.