Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/woowacourse-teams/2021-cvi
Browse files Browse the repository at this point in the history
… into develop
  • Loading branch information
younghoonkwon committed Oct 28, 2021
2 parents c2b2caa + 617170e commit ff01c0b
Show file tree
Hide file tree
Showing 32 changed files with 1,168 additions and 536 deletions.
4 changes: 2 additions & 2 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ subprojects {
'**/CentralVaccinationInformationApplication*',
'**/DummyData*',
'**/CVIControllerAdvice*',
// cvi-publicdata-parser
// domain-cvi-publicdata-parser
'**/Parser*',
// domain-cvi
'**/Sort*',
Expand All @@ -103,7 +103,7 @@ subprojects {
"**/*Test*.*, **/Q*.java, **/*Doc*.java, " +
// api-cvi-api
"**/CentralVaccinationInformationApplication.java, **/DataLoader.java, **/DummyData.java, **/CVIControllerAdvice.java, " +
// cvi-publicdata-parser
// domain-cvi-publicdata-parser
"**/Parser.java, " +
// domain-cvi
"**/Sort.java, **/Filter.java, **/ImageType.java, " +
Expand Down
4 changes: 2 additions & 2 deletions backend/domain-cvi-publicdata-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jacocoTestCoverageVerification { // 코드 커버리지 측정항목 시행
violationRules { // 위반 규칙
rule {
enabled = true
element = 'GROUP'
element = 'BUNDLE'

limit {
counter = 'METHOD'
value = 'COVEREDRATIO'
minimum = 0.90
minimum = 1.0
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,47 +58,6 @@ public static KoreaVaccineParserResponse toVaccineParserResponse(LocalDate targe
), 18, 1, 20, 2634);
}

public static List<VaccinationStatisticResponse> toVaccinationStatisticResponse(LocalDate targetDate) {
return Arrays.asList(
new VaccinationStatisticResponse(19473657, 7146602, targetDate,
473850, 35955, "전국", 19947507, 7182557, BigDecimal.valueOf(39.2), BigDecimal.valueOf(14.3)),
new VaccinationStatisticResponse(3646765, 1329982, targetDate,
77877, 7123, "서울특별시", 3724642, 1337105, BigDecimal.valueOf(39.5), BigDecimal.valueOf(14.4)),
new VaccinationStatisticResponse(1352394, 477845, targetDate,
31252, 2628, "부산광역시", 1383646, 480473, BigDecimal.valueOf(41.8), BigDecimal.valueOf(14.6)),
new VaccinationStatisticResponse(848397, 309317, targetDate,
22726, 2688, "대구광역시", 871123, 312005, BigDecimal.valueOf(37.0), BigDecimal.valueOf(13.4)),
new VaccinationStatisticResponse(1032052, 360923, targetDate,
27394, 1760, "인천광역시", 1059446, 362683, BigDecimal.valueOf(39.8), BigDecimal.valueOf(14.7)),
new VaccinationStatisticResponse(549706, 204415, targetDate,
13700, 830, "광주광역시", 563406, 205245, BigDecimal.valueOf(37.6), BigDecimal.valueOf(14.7)),
new VaccinationStatisticResponse(396793, 124839, targetDate,
11275, 471, "울산광역시", 408068, 125310, BigDecimal.valueOf(37.6), BigDecimal.valueOf(14.0)),
new VaccinationStatisticResponse(523814, 197608, targetDate,
12990, 959, "대전광역시", 536804, 198567, BigDecimal.valueOf(36.8), BigDecimal.valueOf(12.7)),
new VaccinationStatisticResponse(4636237, 1636357, targetDate,
118717, 7895, "경기도", 4754954, 1644252, BigDecimal.valueOf(31.6), BigDecimal.valueOf(10.9)),
new VaccinationStatisticResponse(668422, 273253, targetDate,
14908, 1010, "강원도", 683330, 274263, BigDecimal.valueOf(36.9), BigDecimal.valueOf(11.5)),
new VaccinationStatisticResponse(109202, 37624, targetDate,
3028, 179, "세종특별자치시", 112230, 37803, BigDecimal.valueOf(42.7), BigDecimal.valueOf(15.8)),
new VaccinationStatisticResponse(639514, 240704, targetDate,
15886, 1324, "충청북도", 655400, 242028, BigDecimal.valueOf(42.1), BigDecimal.valueOf(16.1)),
new VaccinationStatisticResponse(849914, 330591, targetDate,
22167, 2054, "충청남도", 872081, 332645, BigDecimal.valueOf(45.6), BigDecimal.valueOf(17.8)),
new VaccinationStatisticResponse(789017, 311961, targetDate,
17331, 1270, "전라북도", 806348, 313231, BigDecimal.valueOf(48.4), BigDecimal.valueOf(19.1)),
new VaccinationStatisticResponse(859228, 344275, targetDate,
19083, 1378, "전라남도", 878311, 345653, BigDecimal.valueOf(42.7), BigDecimal.valueOf(16.0)),
new VaccinationStatisticResponse(1070878, 409752, targetDate,
27263, 2016, "경상북도", 1098141, 411768, BigDecimal.valueOf(40.4), BigDecimal.valueOf(14.8)),
new VaccinationStatisticResponse(1249910, 464110, targetDate,
31098, 1943, "경상남도", 1281008, 466053, BigDecimal.valueOf(39.2), BigDecimal.valueOf(14.3)),
new VaccinationStatisticResponse(251414, 93046, targetDate,
7155, 427, "제주특별자치도", 258569, 93473, BigDecimal.valueOf(42.7), BigDecimal.valueOf(17.8))
);
}

public static WorldVaccinationParserResponse toWorldVaccinationParserResponse(LocalDate targetDate) {
return new WorldVaccinationParserResponse("World", "OWID_WRL",
Arrays.asList(new WorldVaccinationData(targetDate.minusDays(2).toString(), 4327424315L, 2293196690L, 1175939230L,
Expand All @@ -110,18 +69,4 @@ public static WorldVaccinationParserResponse toWorldVaccinationParserResponse(Lo
)
);
}

public static List<VaccinationStatisticResponse> toVaccinationStatisticResponseOnlyWorldRegion(LocalDate targetDate) {
return Arrays.asList(
new VaccinationStatisticResponse(0, 0, targetDate,
0, 0, "World", 2303769251L, 1191535085L, BigDecimal.valueOf(29.3), BigDecimal.valueOf(15.0)),
new VaccinationStatisticResponse(0, 0, targetDate.minusDays(1),
0, 0, "World", 2293196690L, 1175939230L, BigDecimal.valueOf(28.9), BigDecimal.valueOf(14.7))
);
}

public static VaccinationStatisticResponse toSingleWorldVaccinationStatisticResponse(LocalDate targetDate) {
return new VaccinationStatisticResponse(0, 0, targetDate,
0, 0, "World", 2303769251L, 1191535085L, BigDecimal.valueOf(29.3), BigDecimal.valueOf(15.0));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.cvi.service;

import org.ehcache.event.CacheEvent;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.mockito.BDDMockito.willReturn;
import static org.mockito.Mockito.*;

@DisplayName("CacheEventLogger 기능 테스트")
class CacheEventLoggerTest {

@DisplayName("이벤트 호출 확인 - 성공")
@Test
void onEvent() {
//given
CacheEventLogger cacheEventLogger = new CacheEventLogger();
final CacheEvent cacheEvent = mock(CacheEvent.class);
//when
willReturn(1L).given(cacheEvent).getKey();
willReturn("이전 캐시").given(cacheEvent).getOldValue();
willReturn("새로운 캐시").given(cacheEvent).getNewValue();
cacheEventLogger.onEvent(cacheEvent);
//then
verify(cacheEvent, times(1)).getKey();
verify(cacheEvent, times(1)).getOldValue();
verify(cacheEvent, times(1)).getNewValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -43,14 +42,22 @@ class PublicDataServiceTest {

private VaccinationParser vaccinationParser;

public static Stream<Arguments> targetDate() {
public static Stream<Arguments> koreaVaccinationTargetDate() {
return Stream.of(
Arguments.of(LocalDate.now()),
Arguments.of(LocalDate.now().minusDays(1)),
Arguments.of(LocalDate.of(2021, 3, 11))
);
}

public static Stream<Arguments> worldVaccinationTargetDate() {
return Stream.of(
Arguments.of(LocalDate.now()),
Arguments.of(LocalDate.now().minusDays(1)),
Arguments.of(LocalDate.now().minusDays(2))
);
}

@BeforeEach
void init() {
vaccinationParser = mock(VaccinationParser.class);
Expand All @@ -64,7 +71,7 @@ void clear() {

@DisplayName("백신 정종률 데이터 저장 - 성공")
@CustomParameterizedTest
@MethodSource("targetDate")
@MethodSource("koreaVaccinationTargetDate")
void saveVaccinationStatistics(LocalDate targetDate) {
//given
//when
Expand All @@ -77,7 +84,7 @@ void saveVaccinationStatistics(LocalDate targetDate) {

@DisplayName("백신 정종률 데이터 조회 - 성공")
@CustomParameterizedTest
@MethodSource("targetDate")
@MethodSource("koreaVaccinationTargetDate")
void findVaccinationStatistics(LocalDate targetDate) {
//given
//when
Expand Down Expand Up @@ -105,22 +112,37 @@ void findVaccinationStatistics(LocalDate targetDate) {
.isNotEmpty();
assertThat(vaccinationStatistics).extracting(VaccinationStatisticResponse::getTotalFirstRate)
.isNotEmpty();
assertThat(vaccinationStatistics).extracting(VaccinationStatisticResponse::getTotalSecondRate)
.isNotEmpty();
}

@DisplayName("세계 백신 정좁률 데이터 - 저장 - 성공 ")
@Test
void saveWorldVaccinationStatistics() {
@CustomParameterizedTest
@MethodSource("worldVaccinationTargetDate")
void saveWorldVaccinationStatistics(LocalDate targetDate) {
//given
LocalDate targetDate = LocalDate.now();
//when
세계_백신_접종률_저장되어_있음(targetDate);
List<VaccinationStatistic> vaccinationStatistics =
vaccinationStatisticRepository.findByRegionPopulation(RegionPopulation.WORLD);
List<VaccinationStatisticResponse> vaccinationStatisticResponses = 세계_백신_접종률_저장되어_있음(targetDate);
//then
assertThat(vaccinationStatistics).extracting(VaccinationStatistic::getBaseDate)
assertThat(vaccinationStatisticResponses).extracting(VaccinationStatisticResponse::getBaseDate)
.contains(targetDate);
assertThat(vaccinationStatistics).extracting(VaccinationStatistic::getRegionPopulation)
.contains(RegionPopulation.WORLD);
assertThat(vaccinationStatisticResponses).extracting(VaccinationStatisticResponse::getSido)
.contains(RegionPopulation.WORLD.getRegion());
}

@DisplayName("세계 백신 접종률 데이터 - 조회 - 성공")
@CustomParameterizedTest
@MethodSource("worldVaccinationTargetDate")
void findWorldVaccinationStatistics(LocalDate targetDate) {
//given
//when
세계_백신_접종률_저장되어_있음(targetDate);
final List<VaccinationStatisticResponse> vaccinationStatisticResponses = publicDataService.findWorldVaccinationStatistics(targetDate);
//then
assertThat(vaccinationStatisticResponses).extracting(VaccinationStatisticResponse::getBaseDate)
.contains(targetDate);
assertThat(vaccinationStatisticResponses).extracting(VaccinationStatisticResponse::getSido)
.contains(RegionPopulation.WORLD.getRegion());
}

private void 백신_접종률_저장되어_있음(LocalDate targetDate) {
Expand All @@ -129,8 +151,8 @@ void saveWorldVaccinationStatistics() {
publicDataService.saveVaccinationStatistics(targetDate);
}

private void 세계_백신_접종률_저장되어_있음(LocalDate targetDate) {
private List<VaccinationStatisticResponse> 세계_백신_접종률_저장되어_있음(LocalDate targetDate) {
willReturn(toWorldVaccinationParserResponse(targetDate)).given(vaccinationParser).parseToWorldPublicData();
publicDataService.saveWorldVaccinationStatistics(targetDate);
return publicDataService.saveWorldVaccinationStatistics(targetDate);
}
}
1 change: 0 additions & 1 deletion frontend/cypress.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"baseUrl": "http://localhost:9000",
"integrationFolder": "cypress/pages",
"env": {
"cypress-react-selector": {
"root": "#root"
Expand Down
46 changes: 46 additions & 0 deletions frontend/cypress/fixtures/astrazenecaReviewList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"content": "test1",
"createdAt": "2021-07-27T14:56:43.633",
"id": 1,
"vaccinationType": "ASTRAZENECA",
"viewCount": 0,
"likeCount": 3,
"commentCount": 4,
"writer": {
"accessToken": null,
"ageRange": {
"maxAge": 20,
"meaning": "10대",
"minAge": 10
},
"id": 1,
"nickname": "검프",
"socialId": null,
"socialProfileUrl": null,
"socialProvider": null
}
},
{
"content": "test7",
"createdAt": "2021-07-27T14:56:43.633",
"id": 7,
"vaccinationType": "ASTRAZENECA",
"viewCount": 0,
"likeCount": 35,
"commentCount": 40,
"writer": {
"accessToken": null,
"ageRange": {
"maxAge": 20,
"meaning": "10대",
"minAge": 10
},
"id": 1,
"nickname": "검프",
"socialId": null,
"socialProfileUrl": null,
"socialProvider": null
}
}
]
1 change: 1 addition & 0 deletions frontend/cypress/fixtures/commentList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
23 changes: 0 additions & 23 deletions frontend/cypress/fixtures/editReview.json

This file was deleted.

22 changes: 22 additions & 0 deletions frontend/cypress/fixtures/editedReview.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"content": "다음날 되니 좀 아픈것 같아요 ㅠ ㅠ",
"createdAt": "2021-07-28T14:56:43.633",
"id": 8,
"vaccinationType": "MODERNA",
"viewCount": 0,
"likeCount": 310,
"commentCount": 20,
"writer": {
"accessToken": "accessToken",
"ageRange": {
"maxAge": 30,
"meaning": "20대",
"minAge": 20
},
"id": 8,
"nickname": "nickname",
"socialId": "socialId",
"socialProfileUrl": "http://k.kakaocdn.net/dn/xGvcl/btranGk6QWP/uvRGXQeokXgIhPRD0wTPgk/img_640x640.jpg",
"socialProvider": "KAKAO"
}
}
46 changes: 46 additions & 0 deletions frontend/cypress/fixtures/janssenReviewList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"content": "test5",
"createdAt": "2021-07-27T14:56:43.633",
"id": 5,
"vaccinationType": "JANSSEN",
"viewCount": 0,
"likeCount": 36,
"commentCount": 24,
"writer": {
"accessToken": null,
"ageRange": {
"maxAge": 20,
"meaning": "10대",
"minAge": 10
},
"id": 1,
"nickname": "검프",
"socialId": null,
"socialProfileUrl": null,
"socialProvider": null
}
},
{
"content": "test6",
"createdAt": "2021-07-27T14:56:43.633",
"id": 6,
"vaccinationType": "JANSSEN",
"viewCount": 0,
"likeCount": 13,
"commentCount": 43,
"writer": {
"accessToken": null,
"ageRange": {
"maxAge": 20,
"meaning": "10대",
"minAge": 10
},
"id": 1,
"nickname": "검프",
"socialId": null,
"socialProfileUrl": null,
"socialProvider": null
}
}
]
Loading

0 comments on commit ff01c0b

Please sign in to comment.