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

test: 테스트 리팩터링 #458

Merged
merged 25 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
075cf38
test: 시간 제어 구성 및 Activity Fixture 추가
Choi-JJunho Apr 17, 2024
6ba34ac
test: 로그인 테스트 최적화
Choi-JJunho Apr 17, 2024
cc828e6
test: bus API 테스트 수정
Choi-JJunho Apr 18, 2024
bcb62fb
test: community 테스트 수정
Choi-JJunho Apr 22, 2024
a4e8e64
chore: merge develop
Choi-JJunho Apr 22, 2024
ead8105
test: dept 테스트 수정
Choi-JJunho Apr 22, 2024
59079a1
test: dining test 수정
Choi-JJunho Apr 22, 2024
f4e34f2
test: land test 수정
Choi-JJunho Apr 22, 2024
d686938
test: member test 수정
Choi-JJunho Apr 22, 2024
5956f58
test: notification test 수정
Choi-JJunho Apr 22, 2024
1822b69
test: owner test 수정
Choi-JJunho Apr 22, 2024
5f1e5a6
test: ownerShop test 수정
Choi-JJunho Apr 22, 2024
49b0c38
test: shop test 수정
Choi-JJunho Apr 23, 2024
cc0ff14
test: lecture test 수정
Choi-JJunho Apr 23, 2024
bc928ec
test: track test 수정
Choi-JJunho Apr 23, 2024
4bc61c0
test: version test 수정
Choi-JJunho Apr 23, 2024
ba422d7
test: log 제거
Choi-JJunho Apr 23, 2024
59f8b4e
test: SuppressWarnings 추가
Choi-JJunho Apr 23, 2024
b43de97
test: 라인 포맷팅
Choi-JJunho Apr 23, 2024
4cc4876
test: ExtractableResponse var로 대체
Choi-JJunho Apr 23, 2024
25cc39c
test: objectMapper static으로 변경
Choi-JJunho Apr 23, 2024
dbc8026
chore: admin 패키지 위치 수정
Choi-JJunho Apr 24, 2024
763f35f
test: log 제거
Choi-JJunho Apr 24, 2024
998bbb4
test: 불필요한 설정 제거
Choi-JJunho Apr 24, 2024
3e5974c
Merge branch 'develop' of https://github.com/BCSDLab/KOIN_API_V2 into…
Choi-JJunho Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ public class Activity extends BaseEntity {
private boolean isDeleted = false;

@Builder
private Activity(Integer id, String title, String description, String imageUrls, LocalDate date,
boolean isDeleted) {
this.id = id;
private Activity(
String title,
String description,
String imageUrls,
LocalDate date,
boolean isDeleted
) {
this.title = title;
this.description = description;
this.imageUrls = imageUrls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.springframework.web.bind.annotation.RequestParam;

import in.koreatech.koin.domain.admin.land.dto.AdminLandsResponse;
import in.koreatech.koin.domain.land.dto.LandsGroupResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import in.koreatech.koin.domain.admin.land.dto.AdminLandsResponse;
import in.koreatech.koin.domain.admin.land.service.AdminLandService;
import in.koreatech.koin.domain.land.dto.LandsGroupResponse;
import lombok.RequiredArgsConstructor;

@RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package in.koreatech.koin.domain.admin.land.dto;

import static com.fasterxml.jackson.databind.PropertyNamingStrategies.*;
import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import in.koreatech.koin.domain.land.model.Land;
Expand All @@ -26,7 +25,7 @@ public record AdminLandResponse(
@Schema(description = "전세", example = "3500")
String charterFee,

@Schema(description = "삭제(soft delete) 여부", example = "false", required = true)
@Schema(description = "삭제(soft delete) 여부", example = "false", requiredMode = REQUIRED)
Boolean isDeleted
) {
public static AdminLandResponse from(Land land) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package in.koreatech.koin.domain.admin.land.dto;

import static com.fasterxml.jackson.databind.PropertyNamingStrategies.*;
import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.data.domain.Page;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import in.koreatech.koin.domain.land.model.Land;
Expand Down Expand Up @@ -42,7 +40,7 @@ public static AdminLandsResponse of(Page<Land> pagedResult, Criteria criteria) {
pagedResult.getContent()
.stream()
.map(AdminLandResponse::from)
.collect(Collectors.toList())
.toList()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.time.LocalDateTime;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import in.koreatech.koin.domain.bus.model.BusTimetable;
Expand All @@ -25,6 +26,8 @@ public record BusTimetableResponse(
List<? extends BusTimetable> busTimetable,

@Schema(description = "업데이트 시각", example = "2024-04-20 18:00:00", requiredMode = NOT_REQUIRED)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime updatedAt
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ default ExpressBusCache getById(String busRoute) {

List<ExpressBusCache> findAll();

Boolean existsById(String id);
boolean existsById(String id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ public List<? extends BusTimetable> getBusTimetable(BusType busType, String dire
}

public BusTimetableResponse getBusTimetableWithUpdatedAt(BusType busType, String direction, String region){
List<? extends BusTimetable> BusTimetables = getBusTimetable(busType, direction, region);
List<? extends BusTimetable> busTimetables = getBusTimetable(busType, direction, region);

if (busType.equals(BusType.COMMUTING)){
busType = BusType.SHUTTLE;
}

VersionResponse version = versionService.getVersion(busType.name().toLowerCase() + "_bus_timetable");
return new BusTimetableResponse(BusTimetables, version.updatedAt());
return new BusTimetableResponse(busTimetables, version.updatedAt());
}

public List<BusCourseResponse> getBusCourses() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public CityBusOpenApiClient(

public List<CityBusRemainTime> getBusRemainTime(String nodeId) {
Version version = versionRepository.getByType(VersionType.CITY);
if (isCacheExpired(version, clock)) {
if (isCacheExpired(version, clock) || cityBusCacheRepository.findById(nodeId).isEmpty()) {
Choi-JJunho marked this conversation as resolved.
Show resolved Hide resolved
storeRemainTimeByOpenApi();
}
return getCityBusArrivalInfoByCache(nodeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public List<ExpressBusRemainTime> getBusRemainTime(BusStation depart, BusStation
if (!expressBusCacheRepository.existsById(busCacheId)) {
storeRemainTimeByOpenApi(depart.name().toLowerCase(), arrival.name().toLowerCase());
}
return getStoredRemainTime(depart.name().toLowerCase(), arrival.name().toLowerCase());
return getStoredRemainTime(busCacheId);
}

private void storeRemainTimeByOpenApi(String departName, String arrivalName) {
Expand Down Expand Up @@ -139,7 +139,7 @@ private void storeRemainTimeByOpenApi(String departName, String arrivalName) {
private JsonObject getBusApiResponse(String departName, String arrivalName) {
try {
URL url = getBusApiURL(departName, arrivalName);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-type", "application/json");
BufferedReader reader;
Expand Down Expand Up @@ -202,8 +202,7 @@ private List<OpenApiExpressBusArrival> extractBusArrivalInfo(JsonObject jsonObje
}
}

private List<ExpressBusRemainTime> getStoredRemainTime(String departName, String arrivalName) {
String busCacheId = ExpressBusCache.generateId(new ExpressBusRoute(departName, arrivalName));
private List<ExpressBusRemainTime> getStoredRemainTime(String busCacheId) {
Choi-JJunho marked this conversation as resolved.
Show resolved Hide resolved
ExpressBusCache expressBusCache = expressBusCacheRepository.getById(busCacheId);
if (Objects.isNull(expressBusCache)) {
return Collections.emptyList();
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/in/koreatech/koin/domain/community/model/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,16 @@ public List<Board> getChildren() {
}

@Builder
private Board(String tag, String name, boolean isAnonymous, Integer articleCount, boolean isDeleted,
boolean isNotice, Integer parentId, Integer seq) {
private Board(
String tag,
String name,
boolean isAnonymous,
Integer articleCount,
boolean isDeleted,
boolean isNotice,
Integer parentId,
Integer seq
) {
this.tag = tag;
this.name = name;
this.isAnonymous = isAnonymous;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import in.koreatech.koin.domain.community.model.ArticleViewLog;
import in.koreatech.koin.domain.community.model.Board;
import in.koreatech.koin.domain.community.model.BoardTag;
import in.koreatech.koin.global.model.Criteria;
import in.koreatech.koin.domain.community.repository.ArticleRepository;
import in.koreatech.koin.domain.community.repository.ArticleViewLogRepository;
import in.koreatech.koin.domain.community.repository.BoardRepository;
import in.koreatech.koin.domain.user.repository.UserRepository;
import in.koreatech.koin.global.model.Criteria;
import lombok.RequiredArgsConstructor;

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package in.koreatech.koin.domain.coop.dto;

import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

@JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class)
@JsonNaming(value = SnakeCaseStrategy.class)
public record SoldOutRequest(
@Schema(description = "메뉴 고유 ID", example = "1", requiredMode = REQUIRED)
@NotNull(message = "메뉴 ID는 필수입니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ public class TechStack extends BaseEntity {
private boolean isDeleted = false;

@Builder
private TechStack(String imageUrl, String name, String description, Integer trackId, boolean isDeleted) {
private TechStack(
String imageUrl,
String name,
String description,
Integer trackId
) {
this.imageUrl = imageUrl;
this.name = name;
this.description = description;
this.trackId = trackId;
this.isDeleted = isDeleted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.time.Clock;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -273,7 +272,6 @@ public void createEvent(Integer ownerId, Integer shopId, CreateEventRequest shop
Shop shop = getOwnerShopById(shopId, ownerId);
EventArticle eventArticle = EventArticle.builder()
.shop(shop)
.thumbnailImages(new ArrayList<>())
.startDate(shopEventRequest.startDate())
.endDate(shopEventRequest.endDate())
.title(shopEventRequest.title())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public static MenuDetailResponse createForMultipleOption(Menu menu, List<MenuCat
menu.isHidden(),
false,
null,
menu.getMenuOptions().stream().map(InnerOptionPriceResponse::of).toList(), menu.getDescription(),
menu.getMenuOptions().stream().map(InnerOptionPriceResponse::of).toList(),
menu.getDescription(),
shopMenuCategories.stream().map(MenuCategory::getId).toList(),
menu.getMenuImages().stream().map(MenuImage::getImageUrl).toList()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package in.koreatech.koin.domain.shop.model;

import static jakarta.persistence.CascadeType.MERGE;
import static jakarta.persistence.CascadeType.PERSIST;
import static jakarta.persistence.CascadeType.ALL;
import static jakarta.persistence.FetchType.LAZY;
import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;
Expand Down Expand Up @@ -51,7 +50,7 @@ public class EventArticle extends BaseEntity {
@Column(name = "title", nullable = false)
private String title;

@OneToMany(mappedBy = "eventArticle", cascade = {MERGE, PERSIST})
@OneToMany(mappedBy = "eventArticle", orphanRemoval = true, cascade = ALL)
private List<EventArticleImage> thumbnailImages = new ArrayList<>();

/**
Expand Down Expand Up @@ -123,7 +122,6 @@ private EventArticle(
String title,
String content,
User user,
List<EventArticleImage> thumbnailImages,
Integer hit,
String ip,
LocalDate startDate,
Expand All @@ -133,7 +131,6 @@ private EventArticle(
this.title = title;
this.content = content;
this.user = user;
this.thumbnailImages = thumbnailImages;
this.hit = hit;
this.ip = ip;
this.startDate = startDate;
Expand All @@ -152,7 +149,6 @@ public void modifyArticle(
this.content = content;
this.startDate = startDate;
this.endDate = endDate;
this.thumbnailImages.forEach(entityManager::remove);
this.thumbnailImages.clear();
entityManager.flush();
for (String imageUrl : thumbnailImages) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package in.koreatech.koin.domain.shop.model;

import static jakarta.persistence.FetchType.LAZY;
import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

import in.koreatech.koin.global.domain.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
Expand All @@ -28,7 +28,7 @@ public class EventArticleImage extends BaseEntity {
@GeneratedValue(strategy = IDENTITY)
private Integer id;

@ManyToOne(fetch = LAZY)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "event_id", nullable = false)
private EventArticle eventArticle;

Expand All @@ -38,7 +38,10 @@ public class EventArticleImage extends BaseEntity {
private String thumbnailImage;

@Builder
private EventArticleImage(EventArticle eventArticle, String thumbnailImage) {
private EventArticleImage(
EventArticle eventArticle,
String thumbnailImage
) {
this.eventArticle = eventArticle;
this.thumbnailImage = thumbnailImage;
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/in/koreatech/koin/domain/shop/model/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public class Menu extends BaseEntity {
private List<MenuImage> menuImages = new ArrayList<>();

@Builder
private Menu(Integer shopId, String name, String description) {
private Menu(
Integer shopId,
String name,
String description
) {
this.shopId = shopId;
this.name = name;
this.description = description;
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/in/koreatech/koin/domain/shop/model/Shop.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ private Shop(
boolean isDeleted,
boolean isEvent,
String remarks,
Integer hit,
List<ShopCategoryMap> shopCategories,
List<ShopOpen> shopOpens,
List<ShopImage> shopImages,
List<MenuCategory> menuCategories
Integer hit
) {
this.owner = owner;
this.name = name;
Expand All @@ -153,10 +149,6 @@ private Shop(
this.isEvent = isEvent;
this.remarks = remarks;
this.hit = hit;
this.shopCategories = shopCategories;
this.shopOpens = shopOpens;
this.shopImages = shopImages;
this.menuCategories = menuCategories;
}

public void modifyShop(
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/in/koreatech/koin/domain/user/model/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ public class Student {
private User user;

@Builder
private Student(String anonymousNickname, String studentNumber, String department,
UserIdentity userIdentity, boolean isGraduated, User user) {
private Student(
String anonymousNickname,
String studentNumber,
String department,
UserIdentity userIdentity,
boolean isGraduated,
User user
) {
this.anonymousNickname = anonymousNickname;
this.studentNumber = studentNumber;
this.department = department;
Expand Down
Loading
Loading