diff --git a/src/main/java/egovframework/example/exception/EgovAopExceptionTransfer.java b/src/main/java/egovframework/example/exception/EgovAopExceptionTransfer.java index f9b7786..3a436f0 100644 --- a/src/main/java/egovframework/example/exception/EgovAopExceptionTransfer.java +++ b/src/main/java/egovframework/example/exception/EgovAopExceptionTransfer.java @@ -5,6 +5,7 @@ import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.egovframe.rte.fdl.cmmn.aspect.ExceptionTransfer; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; @Aspect public class EgovAopExceptionTransfer { @@ -19,7 +20,7 @@ public void setExceptionTransfer(ExceptionTransfer exceptionTransfer) { private void exceptionTransferService() {} @AfterThrowing(pointcut="exceptionTransferService()", throwing="ex") - public void doAfterThrowingExceptionTransferService(JoinPoint thisJoinPoint, Exception ex) throws Exception { + public void doAfterThrowingExceptionTransferService(JoinPoint thisJoinPoint, Exception ex) throws BaseRuntimeException, Exception { exceptionTransfer.transfer(thisJoinPoint, ex); } diff --git a/src/main/java/egovframework/example/sample/service/EgovSampleService.java b/src/main/java/egovframework/example/sample/service/EgovSampleService.java index bd8d3a0..74b5be6 100644 --- a/src/main/java/egovframework/example/sample/service/EgovSampleService.java +++ b/src/main/java/egovframework/example/sample/service/EgovSampleService.java @@ -17,6 +17,8 @@ import java.util.List; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; + /** * @Class Name : EgovSampleService.java * @Description : EgovSampleService Class @@ -38,9 +40,8 @@ public interface EgovSampleService { * 글을 등록한다. * @param vo - 등록할 정보가 담긴 SampleVO * @return 등록 결과 - * @exception Exception */ - void insertSample(SampleVO vo) throws Exception; + void insertSample(SampleVO vo); /** * 글을 수정한다. @@ -60,9 +61,10 @@ public interface EgovSampleService { * 글을 조회한다. * @param vo - 조회할 정보가 담긴 SampleVO * @return 조회한 글 + * @exception BaseRuntimeException * @exception Exception */ - SampleVO selectSample(SampleVO vo) throws Exception; + SampleVO selectSample(SampleVO vo) throws BaseRuntimeException, Exception; /** * 글 목록을 조회한다. @@ -75,7 +77,6 @@ public interface EgovSampleService { * 글 총 개수를 조회한다. * @param vo - 조회할 정보가 담긴 VO * @return 글 총 개수 - * @exception */ int selectSampleListTotCnt(SampleVO vo); diff --git a/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java b/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java index 58cfb5e..b541256 100644 --- a/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java +++ b/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java @@ -18,6 +18,8 @@ import java.util.List; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; +import org.egovframe.rte.fdl.cmmn.exception.FdlException; import org.egovframe.rte.fdl.idgnr.EgovIdGnrService; import org.springframework.stereotype.Service; @@ -57,14 +59,18 @@ public class EgovSampleServiceImpl extends EgovAbstractServiceImpl implements Eg * 글을 등록한다. * @param vo - 등록할 정보가 담긴 SampleVO * @return 등록 결과 - * @exception Exception */ @Override - public void insertSample(SampleVO vo) throws Exception { + public void insertSample(SampleVO vo) { log.debug(vo.toString()); /** ID Generation Service */ - String id = egovIdGnrService.getNextStringId(); + String id; + try { + id = egovIdGnrService.getNextStringId(); + } catch (FdlException e) { + throw new BaseRuntimeException(e); + } vo.setId(id); log.debug(vo.toString()); @@ -95,13 +101,15 @@ public void deleteSample(SampleVO vo) { * 글을 조회한다. * @param vo - 조회할 정보가 담긴 SampleVO * @return 조회한 글 + * @exception BaseRuntimeException * @exception Exception */ @Override - public SampleVO selectSample(SampleVO vo) throws Exception { + public SampleVO selectSample(SampleVO vo) throws BaseRuntimeException, Exception { SampleVO resultVO = sampleMapper.selectSample(vo); - if (resultVO == null) + if (resultVO == null) { throw processException("info.nodata.msg"); + } return resultVO; } @@ -119,7 +127,6 @@ public List selectSampleList(SampleVO vo) { * 글 총 개수를 조회한다. * @param vo - 조회할 정보가 담긴 VO * @return 글 총 개수 - * @exception */ @Override public int selectSampleListTotCnt(SampleVO vo) { diff --git a/src/main/java/egovframework/example/sample/web/EgovSampleController.java b/src/main/java/egovframework/example/sample/web/EgovSampleController.java index ab60a95..f20c1e9 100644 --- a/src/main/java/egovframework/example/sample/web/EgovSampleController.java +++ b/src/main/java/egovframework/example/sample/web/EgovSampleController.java @@ -17,6 +17,7 @@ import java.util.List; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; import org.egovframe.rte.fdl.property.EgovPropertyService; import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo; import org.springframework.stereotype.Controller; @@ -123,10 +124,9 @@ public String addSampleView( @ModelAttribute SampleVO sampleVO, Model model) { * @param sampleVO - 등록할 정보가 담긴 VO * @param status * @return "forward:/egovSampleList.do" - * @exception Exception */ @PostMapping("/addSample.do") - public String addSample(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindingResult, Model model, SessionStatus status) throws Exception { + public String addSample(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindingResult, Model model, SessionStatus status) { if (bindingResult.hasErrors()) { model.addAttribute("sampleVO", sampleVO); @@ -144,10 +144,11 @@ public String addSample(@Valid @ModelAttribute SampleVO sampleVO, BindingResult * @param sampleVO - 수정할 글 정보가 담긴 VO * @param model * @return "egovSampleRegister" + * @exception BaseRuntimeException * @exception Exception */ @PostMapping("/updateSampleView.do") - public String updateSampleView(@ModelAttribute SampleVO sampleVO, Model model) throws Exception { + public String updateSampleView(@ModelAttribute SampleVO sampleVO, Model model) throws BaseRuntimeException, Exception { SampleVO detail = sampleService.selectSample(sampleVO); detail.setSearchCondition(sampleVO.getSearchCondition()); diff --git a/src/test/java/egovframework/example/exception/EgovAopExceptionTransferTest.java b/src/test/java/egovframework/example/exception/EgovAopExceptionTransferTest.java index ef7d7f0..3114f3c 100644 --- a/src/test/java/egovframework/example/exception/EgovAopExceptionTransferTest.java +++ b/src/test/java/egovframework/example/exception/EgovAopExceptionTransferTest.java @@ -7,6 +7,7 @@ import org.aspectj.lang.JoinPoint; import org.egovframe.rte.fdl.cmmn.aspect.ExceptionTransfer; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -31,7 +32,7 @@ void setUp() { @Test @DisplayName("doAfterThrowingExceptionTransferService - ExceptionTransfer.transfer 위임 확인") - void testDoAfterThrowingDelegatesToExceptionTransfer() throws Exception { + void testDoAfterThrowingDelegatesToExceptionTransfer() throws BaseRuntimeException, Exception { JoinPoint joinPoint = mock(JoinPoint.class); Exception ex = new RuntimeException("서비스 예외"); @@ -42,7 +43,7 @@ void testDoAfterThrowingDelegatesToExceptionTransfer() throws Exception { @Test @DisplayName("setExceptionTransfer - 의존성 주입 후 transfer 호출 가능") - void testSetExceptionTransfer() throws Exception { + void testSetExceptionTransfer() throws BaseRuntimeException, Exception { ExceptionTransfer another = mock(ExceptionTransfer.class); exceptionTransfer.setExceptionTransfer(another); diff --git a/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTest.java b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTest.java index dad4727..3bdacd9 100644 --- a/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTest.java @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.List; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; import org.egovframe.rte.fdl.idgnr.EgovIdGnrService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -72,7 +73,7 @@ void setUp() { @Test @DisplayName("글 수정 - 정상적으로 updateSample을 호출한다") - void updateSample_정상() throws Exception { + void updateSample_정상() { // given doNothing().when(sampleMapper).updateSample(sampleVO); @@ -85,7 +86,7 @@ void setUp() { @Test @DisplayName("글 삭제 - 정상적으로 deleteSample을 호출한다") - void deleteSample_정상() throws Exception { + void deleteSample_정상() { // given doNothing().when(sampleMapper).deleteSample(sampleVO); @@ -98,7 +99,7 @@ void setUp() { @Test @DisplayName("글 단건 조회 - 존재하는 글을 정상적으로 반환한다") - void selectSample_정상() throws Exception { + void selectSample_정상() throws BaseRuntimeException, Exception { // given SampleVO expected = new SampleVO(); expected.setId("SAMPLE-001"); @@ -116,7 +117,7 @@ void setUp() { @Test @DisplayName("글 단건 조회 - 데이터가 없으면 예외가 발생한다") - void selectSample_데이터없음_예외() throws Exception { + void selectSample_데이터없음_예외() { // given when(sampleMapper.selectSample(sampleVO)).thenReturn(null); @@ -127,7 +128,7 @@ void setUp() { @Test @DisplayName("글 목록 조회 - 목록을 정상적으로 반환한다") @SuppressWarnings("unchecked") - void selectSampleList_정상() throws Exception { + void selectSampleList_정상() { // given SampleVO item1 = new SampleVO(); item1.setId("SAMPLE-001"); diff --git a/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java index 7bb8ea6..3c8a295 100644 --- a/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java @@ -4,6 +4,7 @@ import java.time.LocalDateTime; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -34,7 +35,7 @@ class EgovSampleServiceImplTestInsertSampleTest { private EgovSampleService egovSampleService; @Test - void test() throws Exception { + void test() throws BaseRuntimeException, Exception { // given final SampleVO sampleVO = new SampleVO(); diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java index d9bc5cd..ea5dc25 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java @@ -7,6 +7,7 @@ import java.time.LocalDateTime; import java.util.List; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; import org.egovframe.rte.psl.dataaccess.util.EgovMap; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +17,6 @@ import egovframework.example.sample.service.EgovSampleService; import egovframework.example.sample.service.SampleVO; -import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; /** @@ -30,7 +30,6 @@ @SpringBootTest @AutoConfigureMockMvc -@RequiredArgsConstructor @Slf4j class EgovSampleControllerTestAddTest { @@ -44,24 +43,31 @@ class EgovSampleControllerTestAddTest { private EgovSampleService egovSampleService; @Test - void test() throws Exception { + void test() throws BaseRuntimeException, Exception { // given + final SampleVO insertVO = new SampleVO(); + final String now = LocalDateTime.now().toString(); + insertVO.setName("test 삭제대상 카테고리명 " + now); + insertVO.setDescription("test 삭제대상 설명 " + now); + insertVO.setUseYn("Y"); + insertVO.setRegUser("eGov"); + egovSampleService.insertSample(insertVO); + final SampleVO sampleVO = new SampleVO(); - final String now = LocalDateTime.now().toString(); // final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS")); // 카테고리명 - sampleVO.setName("test 이백행 카테고리명 " + now); + sampleVO.setName(insertVO.getName()); // 설명 - sampleVO.setDescription("test 이백행 설명 " + now); + sampleVO.setDescription(insertVO.getDescription()); // 사용여부 - sampleVO.setUseYn("Y"); + sampleVO.setUseYn(insertVO.getUseYn()); // 등록자 - sampleVO.setRegUser("eGov"); + sampleVO.setRegUser(insertVO.getRegUser()); // when mockMvc.perform( @@ -82,7 +88,7 @@ void test() throws Exception { sampleVO.setRecordCountPerPage(10); sampleVO.setFirstIndex(0); sampleVO.setSearchCondition("1"); - sampleVO.setSearchKeyword(sampleVO.getName()); + sampleVO.setSearchKeyword(insertVO.getName()); final List resultList = egovSampleService.selectSampleList(sampleVO); EgovMap result = (EgovMap) resultList.get(0); final SampleVO resultSampleVO = new SampleVO(); diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestDeleteTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestDeleteTest.java index 79bdadc..3abab2f 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestDeleteTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestDeleteTest.java @@ -24,6 +24,7 @@ import java.time.LocalDateTime; import java.util.List; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; import org.egovframe.rte.psl.dataaccess.util.EgovMap; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -55,7 +56,7 @@ class EgovSampleControllerTestDeleteTest { private EgovSampleService egovSampleService; @Test - void test() throws Exception { + void test() throws BaseRuntimeException, Exception { // given - 등록 final SampleVO insertVO = new SampleVO(); final String now = LocalDateTime.now().toString(); diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelectListTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelectListTest.java index b9590a4..f6249de 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelectListTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelectListTest.java @@ -21,6 +21,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -46,7 +47,7 @@ class EgovSampleControllerTestSelectListTest { private MockMvc mockMvc; @Test - void test_목록조회_기본() throws Exception { + void test_목록조회_기본() throws BaseRuntimeException, Exception { mockMvc.perform(get("/egovSampleList.do")) .andDo(print()) .andExpect(status().isOk()) @@ -56,7 +57,7 @@ class EgovSampleControllerTestSelectListTest { } @Test - void test_목록조회_검색조건_이름() throws Exception { + void test_목록조회_검색조건_이름() throws BaseRuntimeException, Exception { mockMvc.perform( get("/egovSampleList.do") .param("searchCondition", "1") @@ -71,7 +72,7 @@ class EgovSampleControllerTestSelectListTest { } @Test - void test_인덱스_리다이렉트() throws Exception { + void test_인덱스_리다이렉트() throws BaseRuntimeException, Exception { mockMvc.perform(get("/")) .andDo(print()) .andExpect(status().isOk()) diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestUpdateTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestUpdateTest.java index bb62d83..32d4f11 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestUpdateTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestUpdateTest.java @@ -24,6 +24,7 @@ import java.time.LocalDateTime; import java.util.List; +import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException; import org.egovframe.rte.psl.dataaccess.util.EgovMap; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -55,7 +56,7 @@ class EgovSampleControllerTestUpdateTest { private EgovSampleService egovSampleService; @Test - void test() throws Exception { + void test() throws BaseRuntimeException, Exception { // given - 등록 final SampleVO insertVO = new SampleVO(); final String now = LocalDateTime.now().toString();