Skip to content

Commit

Permalink
✅ 테스트 수정 : 테스트 데이터 중복 문제 해결 및 트랜잭션 어노테이션 누락 수정
Browse files Browse the repository at this point in the history
- DB에 미리 준비된 SQL 스크립트와 동일한 데이터로 인한 Insert 오류 해결
- 트랜잭션 어노테이션 누락으로 인한 테스트 실패 수정

Ref : #35
  • Loading branch information
rowing0328 committed Nov 19, 2024
1 parent 7f516b6 commit ed0c877
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package darkoverload.itzip.feature.job.service;

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

import darkoverload.itzip.feature.job.controller.request.JobInfoScrapRequest;
import darkoverload.itzip.feature.job.entity.JobInfoScrapEntity;
Expand All @@ -12,15 +14,12 @@
import org.springframework.test.context.jdbc.SqlGroup;
import org.springframework.transaction.annotation.Transactional;

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


@SpringBootTest
@Transactional
@SqlGroup({
@Sql(value = "/sql/jobinfo/scrap/delete-infoscrap-data.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD),
@Sql(value = "/sql/jobinfo/scrap/infoscrap-repository-date.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(value = "/sql/jobinfo/scrap/infoscrap-repository-date.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD),
@Sql(value = "/sql/jobinfo/scrap/delete-infoscrap-data.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
})
@Transactional
@SpringBootTest
@ActiveProfiles("test")
class JobInfoServiceImplTest {

Expand All @@ -31,12 +30,11 @@ class JobInfoServiceImplTest {
private JobInfoScrapRepository jobInfoScrapRepository;

@Test
void 채용정보_스크랩(){
void 채용정보_스크랩() {

// given
JobInfoScrapRequest request = new JobInfoScrapRequest(13L, "test@test.com");


// when
String response = jobInfoService.jobInfoScrap(request);
JobInfoScrapEntity jobInfo = jobInfoScrapRepository.findByJobInfoId(13L, "test@test.com").get();
Expand All @@ -50,15 +48,14 @@ class JobInfoServiceImplTest {
}

@Test
void 채용정보_스크랩_해제(){
void 채용정보_스크랩_해제() {

// given
JobInfoScrapRequest request = new JobInfoScrapRequest(12L, "test@test.com");


//when
String response = jobInfoService.jobInfoScrap(request);


// then
assertEquals(response, "채용정보 스크랩을 취소하였습니다.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import darkoverload.itzip.feature.job.domain.JobInfo;
import darkoverload.itzip.feature.job.entity.JobInfoEntity;
import darkoverload.itzip.feature.job.repository.JobInfoRepository;
import darkoverload.itzip.feature.job.service.JobInfoService;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
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 java.util.List;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Transactional
@SpringBootTest
@ActiveProfiles(profiles = "test")
public class JobInfoScheduleTest {
Expand Down
77 changes: 68 additions & 9 deletions src/test/resources/sql/jobinfo/scrap/infoscrap-repository-date.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,77 @@
insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code, experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name, job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword, location_code, location_name, position_id, posting_date, required_education_code, required_education_name, salary_code, salary_name, title, url, create_date, modify_date) values(11, '1', '1', '접수마감일', 'http://www.saramin.co.kr/zf_user/company-info/view?csn=2208717654&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '에릭슨엘지(주)', '2', 5, 0, '경력5년↑', '2024-09-29 23:59:59', '306', '네트워크·통신·모바일', '104,130,104,118', '2','IT개발·데이터', 'CDMA,모바일,무선통신,텔레콤,통신,네트워크,정보통신,솔루션', '1', '정규직', 'CDMA,모바일,무선통신,텔레콤,통신', '101080','서울 > 금천구', 48919419, '2024-08-30 13:30:48', '8', '대학교졸업(4년)이상', '99', '면접후 결정', '[Ericsson-LG] Operative Product Owner 채용', 'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48919419&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '2024-07-22 10:00:05', '2024-07-23 10:00:05');
insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code,
experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name,
job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword,
location_code, location_name, position_id, posting_date, required_education_code,
required_education_name, salary_code, salary_name, title, url, create_date, modify_date)
values (11, '1', '1', '접수마감일',
'http://www.saramin.co.kr/zf_user/company-info/view?csn=2208717654&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'에릭슨엘지(주)', '2', 5, 0, '경력5년↑', '2024-09-29 23:59:59', '306', '네트워크·통신·모바일', '104,130,104,118', '2', 'IT개발·데이터',
'CDMA,모바일,무선통신,텔레콤,통신,네트워크,정보통신,솔루션', '1', '정규직', 'CDMA,모바일,무선통신,텔레콤,통신', '101080', '서울 > 금천구', 48919419,
'2024-08-30 13:30:48', '8', '대학교졸업(4년)이상', '99', '면접후 결정', '[Ericsson-LG] Operative Product Owner 채용',
'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48919419&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'2024-07-22 10:00:05', '2024-07-23 10:00:05');


insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code, experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name, job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword, location_code, location_name, position_id, posting_date, required_education_code, required_education_name, salary_code, salary_name, title, url, create_date, modify_date) values(12, '1', '1', '접수마감일', 'http://www.saramin.co.kr/zf_user/company-info/view?csn=2208717654&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '에릭슨엘지(주)', '2', 5, 0, '경력5년↑', '2024-09-29 23:59:59', '306', '네트워크·통신·모바일', '104,130,104,118', '2','IT개발·데이터', 'CDMA,모바일,무선통신,텔레콤,통신,네트워크,정보통신,솔루션', '1', '정규직', 'CDMA,모바일,무선통신,텔레콤,통신', '101080','서울 > 금천구', 48919419, '2024-08-30 13:30:48', '8', '대학교졸업(4년)이상', '99', '면접후 결정', '[Ericsson-LG] Operative Product Owner 채용', 'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48919419&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '2024-07-22 10:00:05', '2024-07-23 10:00:05');
insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code,
experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name,
job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword,
location_code, location_name, position_id, posting_date, required_education_code,
required_education_name, salary_code, salary_name, title, url, create_date, modify_date)
values (12, '1', '1', '접수마감일',
'http://www.saramin.co.kr/zf_user/company-info/view?csn=2208717654&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'에릭슨엘지(주)', '2', 5, 0, '경력5년↑', '2024-09-29 23:59:59', '306', '네트워크·통신·모바일', '104,130,104,118', '2', 'IT개발·데이터',
'CDMA,모바일,무선통신,텔레콤,통신,네트워크,정보통신,솔루션', '1', '정규직', 'CDMA,모바일,무선통신,텔레콤,통신', '101080', '서울 > 금천구', 48919419,
'2024-08-30 13:30:48', '8', '대학교졸업(4년)이상', '99', '면접후 결정', '[Ericsson-LG] Operative Product Owner 채용',
'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48919419&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'2024-07-22 10:00:05', '2024-07-23 10:00:05');

insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code, experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name, job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword, location_code, location_name, position_id, posting_date, required_education_code, required_education_name, salary_code, salary_name, title, url, create_date, modify_date) values(13, '1', '1', '접수마감일', 'http://www.saramin.co.kr/zf_user/company-info/view?csn=2118848320&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '(주)넥스트테크놀로지', '1', 0, 0, '신입', '2024-09-22 23:59:59', '308', '정보보안·백신', '90,715,719,751,796,798,2203', '2,8','IT개발·데이터,영업·판매·무역', 'IDS·IPS,네트워크보안,방화벽,보안,정보보안,네트워크영업,솔루션기술영업,IT영업,H/W,S/W,영업', '1', '정규직', 'IDS·IPS,네트워크보안,방화벽,보안,정보보안', '101000','서울 > 서울전체', 48953031, '2024-09-04 15:25:49', '7', '대학졸업(2,3년)이상', '99', '면접후 결정', '보안솔루션 및 네트워크장비 영업', 'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48953031&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '2024-09-11 10:00:05', '2024-09-11 10:00:05');
insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code,
experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name,
job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword,
location_code, location_name, position_id, posting_date, required_education_code,
required_education_name, salary_code, salary_name, title, url, create_date, modify_date)
values (13, '1', '1', '접수마감일',
'http://www.saramin.co.kr/zf_user/company-info/view?csn=2118848320&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'(주)넥스트테크놀로지', '1', 0, 0, '신입', '2024-09-22 23:59:59', '308', '정보보안·백신', '90,715,719,751,796,798,2203', '2,8',
'IT개발·데이터,영업·판매·무역', 'IDS·IPS,네트워크보안,방화벽,보안,정보보안,네트워크영업,솔루션기술영업,IT영업,H/W,S/W,영업', '1', '정규직',
'IDS·IPS,네트워크보안,방화벽,보안,정보보안', '101000', '서울 > 서울전체', 48953031, '2024-09-04 15:25:49', '7', '대학졸업(2,3년)이상', '99',
'면접후 결정', '보안솔루션 및 네트워크장비 영업',
'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48953031&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'2024-09-11 10:00:05', '2024-09-11 10:00:05');

insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code, experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name, job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword, location_code, location_name, position_id, posting_date, required_education_code, required_education_name, salary_code, salary_name, title, url, create_date, modify_date) values(14, '1', '1', '접수마감일', 'http://www.saramin.co.kr/zf_user/company-info/view?csn=8558702525&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '(주)다담서포트', '2', 15, 3, '경력 3~15년', '2024-09-06 12:00:00', '304', '쇼핑몰·오픈마켓', '209,1483,1487,1490,1501,1504,1513,1600,1611,1614,1981,291', '2,15,21','IT개발·데이터,디자인,고객상담·TM', '쇼핑몰,오픈마켓,전자상거래,CSS,광고디자인,로고디자인,문구디자인,완구디자인,일러스트레이터,컨셉디자인,일러스트,HTML,PhotoShop,고객관리,Spring', '1', '정규직', '쇼핑몰,오픈마켓,전자상거래', '101040','서울 > 강서구', 48952926, '2024-09-04 15:18:36', '0', '학력무관', '99', '면접후 결정', '[베스트냅킨] 일회용품 쇼핑몰 편집 디자이너 모집', 'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48952926&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '2024-09-11 10:00:05', '2024-09-11 10:00:05');

insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code, experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name, job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword, location_code, location_name, position_id, posting_date, required_education_code, required_education_name, salary_code, salary_name, title, url, create_date, modify_date) values(15, '1', '1', '접수마감일', 'http://www.saramin.co.kr/zf_user/company-info/view?csn=3148146845&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '(주)엠티지', '2', 0, 10, '경력10년↑', '2024-10-04 23:59:59', '306', '네트워크·통신·모바일', '81,128,151,153,167,813,1011,1014,1015,1029,1126,1148,1660,2218', '11,2,16,9','IT개발·데이터,연구·R&D,생산,기획·전략', '무선통신,통신,기술지원,임베디드,FPGA,H/W,S/W,광학설계,구조해석/설계,기구설계,기술설계,회로설계,도면해독,사업관리,자동차,기계설계,안테나설계,안테나특성분석,도면규격화,보드설계,외주제작관리', '1', '정규직', '무선통신,통신', '105040','대전 > 유성구', 48952923, '2024-09-04 15:18:29', '8', '대학교졸업(4년)이상', '99', '면접후 결정', '연구본부 기계팀 경력직 채용 [근무지: 대전 유성구]', 'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48952923&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api', '2024-07-22 10:00:05', '2024-07-23 10:00:05');
insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code,
experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name,
job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword,
location_code, location_name, position_id, posting_date, required_education_code,
required_education_name, salary_code, salary_name, title, url, create_date, modify_date)
values (14, '1', '1', '접수마감일',
'http://www.saramin.co.kr/zf_user/company-info/view?csn=8558702525&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'(주)다담서포트', '2', 15, 3, '경력 3~15년', '2024-09-06 12:00:00', '304', '쇼핑몰·오픈마켓',
'209,1483,1487,1490,1501,1504,1513,1600,1611,1614,1981,291', '2,15,21', 'IT개발·데이터,디자인,고객상담·TM',
'쇼핑몰,오픈마켓,전자상거래,CSS,광고디자인,로고디자인,문구디자인,완구디자인,일러스트레이터,컨셉디자인,일러스트,HTML,PhotoShop,고객관리,Spring', '1', '정규직',
'쇼핑몰,오픈마켓,전자상거래', '101040', '서울 > 강서구', 48952926, '2024-09-04 15:18:36', '0', '학력무관', '99', '면접후 결정',
'[베스트냅킨] 일회용품 쇼핑몰 편집 디자이너 모집',
'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48952926&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'2024-09-11 10:00:05', '2024-09-11 10:00:05');

insert into job_infos(id, active, close_type_code, close_type_name, company_href, company_name, experience_code,
experience_max, experience_min, experience_name, expiration_date, industry_code, industry_name,
job_code, job_mid_code, job_mid_name, job_name, job_type_code, job_type_name, keyword,
location_code, location_name, position_id, posting_date, required_education_code,
required_education_name, salary_code, salary_name, title, url, create_date, modify_date)
values (15, '1', '1', '접수마감일',
'http://www.saramin.co.kr/zf_user/company-info/view?csn=3148146845&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'(주)엠티지', '2', 0, 10, '경력10년↑', '2024-10-04 23:59:59', '306', '네트워크·통신·모바일',
'81,128,151,153,167,813,1011,1014,1015,1029,1126,1148,1660,2218', '11,2,16,9', 'IT개발·데이터,연구·R&D,생산,기획·전략',
'무선통신,통신,기술지원,임베디드,FPGA,H/W,S/W,광학설계,구조해석/설계,기구설계,기술설계,회로설계,도면해독,사업관리,자동차,기계설계,안테나설계,안테나특성분석,도면규격화,보드설계,외주제작관리',
'1', '정규직', '무선통신,통신', '105040', '대전 > 유성구', 48952923, '2024-09-04 15:18:29', '8', '대학교졸업(4년)이상', '99',
'면접후 결정', '연구본부 기계팀 경력직 채용 [근무지: 대전 유성구]',
'http://www.saramin.co.kr/zf_user/jobs/relay/view?rec_idx=48952923&utm_source=job-search-api&utm_medium=api&utm_campaign=saramin-job-search-api',
'2024-07-22 10:00:05', '2024-07-23 10:00:05');

insert into users(id, authority, email, nickname, password, create_date, modify_date)
values(100, 'USER','test@test.com', '아름다운 135번째 돌고래', '$2a$10$5RifHVaUMq.7IXyJK40kpuaWzfhRBsPgdq1CAhB6LGXdwbxep0.Ba','2024-07-22 10:13:19.129274','2024-07-22 10:13:19.129274');

values (100, 'USER', 'test@test.com', '아름다운 135번째 돌고래', '$2a$10$5RifHVaUMq.7IXyJK40kpuaWzfhRBsPgdq1CAhB6LGXdwbxep0.Ba',
'2024-07-22 10:13:19.129274', '2024-07-22 10:13:19.129274');

insert into job_info_scraps(id, job_id, user_id, create_date, modify_date)
values(100, 12, 100, '2024-09-09 15:30:11', '2024-09-09 15:30:11')
values (100, 12, 100, '2024-09-09 15:30:11', '2024-09-09 15:30:11');

0 comments on commit ed0c877

Please sign in to comment.