-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
288 additions
and
90 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
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/autoever2/cartag/domain/car/CarTypeDto.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,28 @@ | ||
package autoever2.cartag.domain.car; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@Schema(description = "차종 ID와 이름, 이미지를 반환하는 dto") | ||
public class CarTypeDto { | ||
|
||
@Schema(description = "차종 ID, 차량(트림) ID와 다름", example = "1") | ||
private int carTypeId; | ||
@Schema(description = "차종 이미지", example = "/cartype/palisade/palisade-thumbnail.png") | ||
private String carTypeImage; | ||
@Schema(description = "차종 명", example = "팰리세이드") | ||
private String carTypeName; | ||
|
||
@Builder | ||
public CarTypeDto(int carTypeId, String carTypeImage, String carTypeName) { | ||
this.carTypeId = carTypeId; | ||
this.carTypeImage = carTypeImage; | ||
this.carTypeName = carTypeName; | ||
} | ||
} |
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
13 changes: 0 additions & 13 deletions
13
backend/src/test/java/autoever2/cartag/CartagApplicationTests.java
This file was deleted.
Oops, something went wrong.
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
73 changes: 73 additions & 0 deletions
73
backend/src/test/java/autoever2/cartag/integration/CarTest.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,73 @@ | ||
package autoever2.cartag.integration; | ||
|
||
import autoever2.cartag.controller.CarController; | ||
import autoever2.cartag.domain.car.CarDefaultDto; | ||
import autoever2.cartag.domain.car.CarDto; | ||
import autoever2.cartag.domain.car.CarTypeDto; | ||
import autoever2.cartag.exception.EmptyDataException; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.jdbc.Sql; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
@ActiveProfiles("test") | ||
@Sql(scripts = {"classpath:/insert/insertCar-h2.sql"}) | ||
public class CarTest { | ||
@Autowired | ||
CarController controller; | ||
|
||
@Test | ||
@DisplayName("/api/cars/types?cartype=1 통합테스트") | ||
void testCarTypes() { | ||
List<CarDto> cars = controller.carTrimInfo(1); | ||
assertEquals("Le Blanc", cars.get(0).getTrim()); | ||
assertEquals(40000000, cars.get(1).getCarDefaultPrice()); | ||
assertEquals("image_1", cars.get(2).getOuterImage()); | ||
assertEquals("image_2", cars.get(3).getInnerImage()); | ||
assertThrows(EmptyDataException.class, () -> { | ||
controller.carTrimInfo(100); | ||
}); | ||
} | ||
|
||
@Test | ||
@DisplayName("/api/cars/list 테스트") | ||
void testCarTypeList() { | ||
List<CarTypeDto> carTypeList = new ArrayList<>(); | ||
carTypeList.add(CarTypeDto.builder() | ||
.carTypeId(1) | ||
.carTypeName("펠리세이드") | ||
.carTypeImage("image_1") | ||
.build()); | ||
carTypeList.add(CarTypeDto.builder() | ||
.carTypeId(2) | ||
.carTypeImage("/cartype/santafe.png") | ||
.carTypeName("싼타페") | ||
.build()); | ||
carTypeList.add(CarTypeDto.builder() | ||
.carTypeId(3) | ||
.carTypeImage("/cartype/the-all-new-kona-hybrid.png") | ||
.carTypeName("디 올 뉴 코나 Hybrid") | ||
.build()); | ||
|
||
assertThat(controller.getCarTypeList()).usingRecursiveComparison().isEqualTo(carTypeList); | ||
} | ||
} |
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
Oops, something went wrong.