Skip to content

Commit

Permalink
Merge pull request #306 from softeerbootcamp-2nd/dev
Browse files Browse the repository at this point in the history
[FEAT] 8.18 (금) 데모 버전
  • Loading branch information
jijiseong authored Aug 18, 2023
2 parents e2b1323 + 95b8a25 commit 875adce
Show file tree
Hide file tree
Showing 23 changed files with 479 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public List<OuterColorDto> findOuterColorCarByCarId(int carId) {
}

public Optional<String> findOuterColorImagesByColorId(int colorId){
String sql = "select color_car_image from ColorCarMapper where color_id = :colorId";
String sql = "select color_car_image from ColorCarMapper cm inner join Color as c " +
"on cm.color_id = c.color_id where c.color_id = :colorId and c.is_outer_color = 1";
try {
SqlParameterSource param = new MapSqlParameterSource()
.addValue("colorId", colorId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class ModelService {

public List<ModelShortDataDto> getModelTypeData(int carId) {
List<ModelShortMappedDto> modelData = modelRepository.findAllModelTypeData(carId);
if (modelData.isEmpty()) {
throw new EmptyDataException(ErrorCode.RESOURCE_NOT_FOUND);
}
Long carBoughtCount = carRepository.findCarBoughtCountByCarId(carId).orElse(0L);
List<ModelShortMappedDto> powerTrainData = modelData.stream().filter(modelShortMappedDto -> modelShortMappedDto.getModelTypeId() == 1).collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void getTrimList() throws Exception {
//when
ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.get("/api/cars/types").param("cartype", String.valueOf(carType)));

System.out.println("jsonPath(\"$[3].options[0]\") = " + jsonPath("$[3].options[0]"));
//then
resultActions.andExpect(status().isOk())
.andExpect(jsonPath("$[0].trim").value("Le Blanc"))
Expand Down
61 changes: 61 additions & 0 deletions backend/src/test/java/autoever2/cartag/integration/ColorTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package autoever2.cartag.integration;

import autoever2.cartag.controller.ColorController;
import autoever2.cartag.domain.color.InnerColorPercentDto;
import autoever2.cartag.domain.color.OuterColorPercentDto;
import autoever2.cartag.exception.EmptyDataException;
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 java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

@SpringBootTest
@Transactional
@ActiveProfiles("test")
@Sql(scripts = {"classpath:/insert/insertColor-h2.sql"})
public class ColorTest {

@Autowired
ColorController controller;

@Test
@DisplayName("선택한 car_id에 따라 외장 색상 리스트를 반환합니다.")
void getOuterColorList() {
List<OuterColorPercentDto> outerColors = controller.carOuterColorInfo(1);
assertEquals("천연 퀄팅(블랙)", outerColors.get(0).getColorName());
assertEquals("image_2", outerColors.get(1).getColorImage());
assertThrows(EmptyDataException.class, () -> {
controller.carOuterColorInfo(2);
});
}

@Test
@DisplayName("선택한 car_id에 따라 내장 색상 리스트를 반환합니다.")
void getInnerColorList() {
List<InnerColorPercentDto> innerColors = controller.carInnerColorInfo(1);
assertEquals("퍼플 그레이 펄", innerColors.get(0).getColorName());
assertEquals("image_3", innerColors.get(0).getColorImage());
assertThrows(EmptyDataException.class, () -> {
controller.carInnerColorInfo(2);
});
}

@Test
@DisplayName("선택 차량의 외장색상 이미지 리스트를 반환합니다")
void getOuterColorImageList() {
List<String> images = controller.carOuterColorImageInfo(1);
assertEquals(60, images.size());
assertEquals("red_image_30.jpg", images.get(29));
assertThrows(EmptyDataException.class, () -> {
controller.carOuterColorImageInfo(3);
});
}
}
68 changes: 68 additions & 0 deletions backend/src/test/java/autoever2/cartag/integration/ModelTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package autoever2.cartag.integration;

import autoever2.cartag.controller.ModelController;
import autoever2.cartag.domain.model.ModelDetailMappedDto;
import autoever2.cartag.domain.model.ModelEfficiencyDataDto;
import autoever2.cartag.domain.model.ModelShortDataDto;
import autoever2.cartag.domain.model.PowerTrainDataDto;
import autoever2.cartag.exception.EmptyDataException;
import org.junit.jupiter.api.Assertions;
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 java.util.List;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
@ActiveProfiles("test")
@Transactional
@Sql({"classpath:insert/insert-model-h2.sql"})
public class ModelTest {

@Autowired
ModelController controller;

@Test
@DisplayName("차량 모델 페이지에서 하단의 리스트(파워트레인 등)를 반환하는 api 테스트")
void getModelList() {
List<ModelShortDataDto> trimModels = controller.getTrimModelType(1);
assertEquals("디젤2.2", trimModels.get(0).getModelName());
assertEquals(0, trimModels.get(1).getModelPrice());
assertEquals("구동방식", trimModels.get(2).getModelTypeName());
assertThrows(EmptyDataException.class, () -> {
controller.getTrimModelType(9);
});

PowerTrainDataDto hmgData = trimModels.get(0).getHmgData();
assertEquals("45.0/1750~2750", hmgData.getMaxKgfm());
assertEquals(1.0, hmgData.getRatioKgfm());
}

@Test
@DisplayName("모델명과 설명, 이미지 반환하는 api 테스트")
void getModelDescriptionAndImage() {
ModelDetailMappedDto modelDetail = controller.getModelDetail(1);
assertEquals("디젤2.2", modelDetail.getModelName());
assertEquals("/model/diesel2-2.jpg", modelDetail.getModelImage());
assertEquals("파워트레인", modelDetail.getModelTypeName());
assertEquals("높은 토크로 파워풀한 드라이빙이 가능하며, 차급대비 연비 효율이 우수합니다", modelDetail.getOptionDescription());
}

@Test
@DisplayName("파워트레인과 구동방식의 조합으로 나온 효츌 HMG값 반환")
void getHmgData() {
assertThrows(EmptyDataException.class, () -> {
controller.getPowerTrainData(1, 1);
});

ModelEfficiencyDataDto powerTrainData = controller.getPowerTrainData(1, 3);
assertEquals("2,199cc", powerTrainData.getDisplacement());
assertEquals("12.16km/s", powerTrainData.getAverageFuel());
}
}
80 changes: 80 additions & 0 deletions backend/src/test/java/autoever2/cartag/integration/OptionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package autoever2.cartag.integration;

import autoever2.cartag.controller.OptionController;
import autoever2.cartag.domain.option.DefaultOptionDto;
import autoever2.cartag.domain.option.OptionDetailDto;
import autoever2.cartag.domain.option.OptionHmgDataVo;
import autoever2.cartag.domain.option.SubOptionDto;
import autoever2.cartag.exception.EmptyDataException;
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 java.util.List;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
@Transactional
@ActiveProfiles("test")
@Sql({"classpath:insert/insert-suboption-h2.sql"})
public class OptionTest {
@Autowired
OptionController controller;

@Test
@DisplayName("추가 옵션 데이터와 선택 비율(%) 및 HMG 데이터 존재 여부 List 제공 테스트")
void getOptionDataAndHmgDataList() {
List<SubOptionDto> subOptionList = controller.getSubOptionList(1);
assertEquals(6, subOptionList.size());
assertEquals("2열 통풍 시트", subOptionList.get(0).getOptionName());
assertEquals("/images/options/sub/2seats.jpg", subOptionList.get(0).getOptionImage());
assertEquals(100000, subOptionList.get(0).getOptionPrice());
assertEquals("상세품목", subOptionList.get(0).getOptionCategoryName());
}

@Test
@DisplayName("추가옵션 데이터 상세정보 및 이미지, HMG가 존재한다면(비어있다면 비어있는 부분을 Null) 태스트")
void getOptionDetail() {
OptionDetailDto subOptionDetail = controller.getSubOptionDetail(1, 1);
assertEquals("2열 통풍 시트", subOptionDetail.getOptionName());
assertEquals("시동이 걸린 상태에서 해당 좌석의 통풍 스위치를 누르면 표시등이 켜지면서 해당 좌석에 바람이 나오는 편의장치입니다.", subOptionDetail.getOptionDescription());

OptionDetailDto subOptionDto = controller.getSubOptionDetail(1, 69);
assertEquals("컴포트2", subOptionDto.getOptionName());

List<OptionDetailDto> subOptionList = subOptionDto.getSubOptionList();
assertEquals(2, subOptionList.size());
}

@Test
@DisplayName("기본옵션 데이터 상세정보 및 이미지, HMG가 존재한다면(비어있다면 비어있는 부분을 Null) 보냄 테스트")
void getDataAndImage() {
OptionDetailDto defaultOptionDetail = controller.getDefaultOptionDetail(1, 1);
assertEquals("상세품목", defaultOptionDetail.getCategoryName());
assertEquals("2열 통풍 시트", defaultOptionDetail.getOptionName());
assertEquals("시동이 걸린 상태에서 해당 좌석의 통풍 스위치를 누르면 표시등이 켜지면서 해당 좌석에 바람이 나오는 편의장치입니다.", defaultOptionDetail.getOptionDescription());
assertFalse(defaultOptionDetail.isPackage());
assertThrows(EmptyDataException.class, () -> {
controller.getDefaultOptionDetail(2, 1);
});

OptionHmgDataVo hmgData = defaultOptionDetail.getHmgData();
assertEquals(38.0, hmgData.getOptionUsedCount());
}

@Test
@DisplayName("기본 옵션 데이터와 및 HMG 데이터 존재 여부 List 제공 테스트")
void getOptionAndData(){
List<DefaultOptionDto> defaultOptionList = controller.getDefaultOptionList(1);
assertEquals(3, defaultOptionList.size());

DefaultOptionDto defaultOptionDto = defaultOptionList.get(1);
assertEquals("적외선 무릎 워머", defaultOptionDto.getOptionName());
assertEquals("악세사리", defaultOptionDto.getOptionCategoryName());
}
}
39 changes: 39 additions & 0 deletions backend/src/test/java/autoever2/cartag/integration/TrimTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package autoever2.cartag.integration;

import autoever2.cartag.controller.TrimController;
import autoever2.cartag.domain.car.CarDto;
import autoever2.cartag.exception.EmptyDataException;
import org.junit.jupiter.api.Assertions;
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 java.util.List;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
@Transactional
@ActiveProfiles("test")
@Sql(scripts = {"classpath:/insert/insertCar-h2.sql"})
public class TrimTest {
@Autowired
TrimController controller;

@Test
@DisplayName("cartype에 종속적인 차량 리스트 반환 api를 테스트 합니다.")
void testCarController() {
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(2);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import autoever2.cartag.exception.ErrorCode;
import autoever2.cartag.repository.CarRepository;
import autoever2.cartag.repository.OptionRepository;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand All @@ -19,7 +18,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import javax.swing.text.html.Option;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -150,6 +149,8 @@ void getModelTypeData() {
assertEquals(60, imageFiles.size());
assertEquals(2, result_inner.get(4).getColorBoughtPercent());
assertEquals("어비스 블랙펄", result_outer.get(0).getColorName());
assertEquals(100000L, result_inner.get(0).getColorPrice());
assertEquals(2, result_inner.get(1).getColorBoughtPercent());
assertThatThrownBy(() -> service.changeImageToImages(2)).isInstanceOf(EmptyDataException.class);
assertThatThrownBy(() -> service.findInnerColorByCarId(2)).isInstanceOf(EmptyDataException.class);
assertThatThrownBy(() -> service.findOuterColorByCarId(2)).isInstanceOf(EmptyDataException.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package autoever2.cartag.service;

import autoever2.cartag.domain.model.*;
import autoever2.cartag.domain.model.ModelDetailMappedDto;
import autoever2.cartag.domain.model.ModelEfficiencyDataDto;
import autoever2.cartag.domain.model.ModelShortDataDto;
import autoever2.cartag.domain.model.ModelShortMappedDto;
import autoever2.cartag.exception.EmptyDataException;
import autoever2.cartag.repository.CarRepository;
import autoever2.cartag.repository.ModelRepository;
import org.assertj.core.api.SoftAssertions;
import org.assertj.core.api.junit.jupiter.InjectSoftAssertions;
import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -20,7 +22,6 @@
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, SoftAssertionsExtension.class})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/cards/ModelTypeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ModelTypeCard({
<ModelTypeDesc>{desc}</ModelTypeDesc>
<ModelTypeTitle>{title}</ModelTypeTitle>
<ModelTypePrice>
+{price}<CheckIcon active={active} />
+{price.toLocaleString()}<CheckIcon active={active} />
</ModelTypePrice>
</Wrapper>
);
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/cards/OptionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function OptionCard({
<DefaultInfo>기본포함</DefaultInfo>
) : (
<OptionPrice>
+{price}<CheckIcon active={active} />
+{price.toLocaleString()}<CheckIcon active={active} />
</OptionPrice>
);

Expand Down Expand Up @@ -98,7 +98,13 @@ const OptionCardInfo = styled.div`

const OptionTitle = styled.div`
${HeadingEn4}
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
`;

const OptionPrice = styled.div`
${HeadingKrMedium7}
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/cards/OuterColorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function OuterColorCard({
</ColorDesc>
<ColorName>{name}</ColorName>
<Row>
<ColorPrice>+ {price}</ColorPrice>
<ColorPrice>+ {price.toLocaleString()} </ColorPrice>
<CheckIcon active={active} />
</Row>
</DescWrapper>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/common/banner/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const SubTitle = styled.p`
`;

const Title = styled.p`
position: relative;
z-index: 3;
color: ${({ theme }) => theme.color.primaryColor700};
${HeadingKrBold1}
`;
1 change: 0 additions & 1 deletion frontend/src/components/common/hmgTag/HmgTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export interface IHmgTag {
}

export default function HmgTag({ size = 'medium' }: IHmgTag) {
// Todo. ">" 를 svg 아이콘으로 바꾸기
return <Wrapper $size={size}>HMG Data {size === 'large' ? '>' : null}</Wrapper>;
}
const Wrapper = styled.div<{ $size: sizeType }>`
Expand Down
Loading

0 comments on commit 875adce

Please sign in to comment.