-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#83] test : 식당 이름으로 고정 메뉴 조회를 테스트 한다
- Loading branch information
1 parent
2cd2361
commit 65720be
Showing
11 changed files
with
90 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 29 additions & 29 deletions
58
src/main/java/ssu/eatssu/domain/restaurant/entity/TemporalRestaurant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package ssu.eatssu.domain.restaurant.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import ssu.eatssu.domain.menu.entity.Meal; | ||
import ssu.eatssu.domain.menu.entity.Menu; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class TemporalRestaurant { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "restaurant_id") | ||
private Long id; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private Restaurant restaurantName; | ||
|
||
@OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL) | ||
private List<Menu> menus; | ||
|
||
@OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL) | ||
private List<Meal> meals; | ||
} | ||
//package ssu.eatssu.domain.restaurant.entity; | ||
// | ||
//import jakarta.persistence.*; | ||
//import lombok.AccessLevel; | ||
//import lombok.Getter; | ||
//import lombok.NoArgsConstructor; | ||
// | ||
//import java.util.List; | ||
//import ssu.eatssu.domain.menu.entity.Meal; | ||
//import ssu.eatssu.domain.menu.entity.Menu; | ||
// | ||
//@Entity | ||
//@Getter | ||
//@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
//public class TemporalRestaurant { | ||
// | ||
// @Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
// @Column(name = "restaurant_id") | ||
// private Long id; | ||
// | ||
// @Enumerated(EnumType.STRING) | ||
// private Restaurant restaurantName; | ||
// | ||
// @OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL) | ||
// private List<Menu> menus; | ||
// | ||
// @OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL) | ||
// private List<Meal> meals; | ||
//} |
26 changes: 13 additions & 13 deletions
26
src/main/java/ssu/eatssu/domain/restaurant/repository/RestaurantRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package ssu.eatssu.domain.restaurant.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import ssu.eatssu.domain.restaurant.entity.Restaurant; | ||
import ssu.eatssu.domain.restaurant.entity.TemporalRestaurant; | ||
|
||
import java.util.Optional; | ||
|
||
public interface RestaurantRepository extends JpaRepository<TemporalRestaurant, Long> { | ||
|
||
Optional<TemporalRestaurant> findByRestaurantName(Restaurant restaurantName); | ||
|
||
} | ||
//package ssu.eatssu.domain.restaurant.repository; | ||
// | ||
//import org.springframework.data.jpa.repository.JpaRepository; | ||
//import ssu.eatssu.domain.restaurant.entity.Restaurant; | ||
//import ssu.eatssu.domain.restaurant.entity.TemporalRestaurant; | ||
// | ||
//import java.util.Optional; | ||
// | ||
//public interface RestaurantRepository extends JpaRepository<TemporalRestaurant, Long> { | ||
// | ||
// Optional<TemporalRestaurant> findByRestaurantName(Restaurant restaurantName); | ||
// | ||
//} |
38 changes: 38 additions & 0 deletions
38
src/test/java/ssu/eatssu/domain/menu/service/MenuServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ssu.eatssu.domain.menu.service; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import ssu.eatssu.domain.menu.dto.MenuResponse.MenuInformationResponse; | ||
import ssu.eatssu.domain.menu.entity.Menu; | ||
import ssu.eatssu.domain.menu.repository.MenuRepository; | ||
import ssu.eatssu.domain.restaurant.entity.Restaurant; | ||
|
||
@SpringBootTest | ||
class MenuServiceTest { | ||
|
||
@Autowired | ||
private MenuService menuService; | ||
|
||
@Autowired | ||
private MenuRepository menuRepository; | ||
|
||
@Test | ||
void 식당_이름으로_고정_메뉴를_조회한다() { | ||
// given | ||
List<Menu> menus = new ArrayList<>(); | ||
Restaurant foodCourt = Restaurant.from("푸드 코트"); | ||
menus.add(Menu.createFixed("라면", foodCourt, 3000)); | ||
menus.add(Menu.createFixed("떡볶이", foodCourt, 5000)); | ||
menus.add(Menu.createFixed("짜게치", foodCourt, 4000)); | ||
menuRepository.saveAll(menus); | ||
|
||
// when & then | ||
Assertions.assertThat(menuService.findMenusByRestaurant(foodCourt)) | ||
.extracting(MenuInformationResponse::getName) | ||
.containsExactly("라면", "떡볶이", "짜게치"); | ||
} | ||
} |