From 93c1bba8f1ce6989c83ae978f80764d0bf5989b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=B0=B1=ED=96=89?= Date: Tue, 14 Jul 2026 21:48:27 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor(sample):=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=98=88=EC=99=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sample/service/EgovSampleService.java | 15 ++++++------- .../service/impl/EgovSampleServiceImpl.java | 19 +++++++---------- .../sample/service/impl/SampleMapper.java | 21 +++++++------------ .../sample/web/EgovSampleController.java | 19 +++++++---------- .../impl/EgovSampleServiceImplTest.java | 8 +++---- 5 files changed, 34 insertions(+), 48 deletions(-) diff --git a/src/main/java/egovframework/example/sample/service/EgovSampleService.java b/src/main/java/egovframework/example/sample/service/EgovSampleService.java index 06f2696..14db5d6 100644 --- a/src/main/java/egovframework/example/sample/service/EgovSampleService.java +++ b/src/main/java/egovframework/example/sample/service/EgovSampleService.java @@ -24,7 +24,8 @@ * @ * @ 수정일 수정자 수정내용 * @ --------- --------- ------------------------------- - * @ 2009.03.16 최초생성 + * @ 2009.03.16 최초생성 + * 2026.07.14 이백행 [2026년 컨트리뷰션] 불필요한 예외 제거 * * @author 개발프레임웍크 실행환경 개발팀 * @since 2009. 03.16 @@ -47,23 +48,21 @@ public interface EgovSampleService { * 글을 수정한다. * @param vo - 수정할 정보가 담긴 SampleVO * @return void형 - * @exception Exception */ - void updateSample(SampleVO vo) throws Exception; + void updateSample(SampleVO vo); /** * 글을 삭제한다. * @param vo - 삭제할 정보가 담긴 SampleVO * @return void형 - * @exception Exception */ - void deleteSample(SampleVO vo) throws Exception; + void deleteSample(SampleVO vo); /** * 글을 조회한다. * @param vo - 조회할 정보가 담긴 SampleVO * @return 조회한 글 - * @exception Exception + * @exception Exception */ SampleVO selectSample(SampleVO vo) throws Exception; @@ -71,15 +70,13 @@ public interface EgovSampleService { * 글 목록을 조회한다. * @param searchVO - 조회할 정보가 담긴 VO * @return 글 목록 - * @exception Exception */ - List selectSampleList(SampleVO vo) throws Exception; + List selectSampleList(SampleVO vo); /** * 글 총 갯수를 조회한다. * @param searchVO - 조회할 정보가 담긴 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 9e42f2a..cae84f7 100644 --- a/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java +++ b/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java @@ -33,10 +33,11 @@ * @ * @ 수정일 수정자 수정내용 * @ --------- --------- ------------------------------- - * @ 2009.03.16 최초생성 - * @ 2026.06.19 [2026년 컨트리뷰션] 문자열 기반 설정 제거 - * @ 2026.06.25 [2026년 컨트리뷰션] 생성자 주입으로 변경 - * @ 2026.07.04 정찬영 [2026년 컨트리뷰션] 미사용 import 제거 및 @Slf4j로 로거 선언 통일 + * @ 2009.03.16 최초생성 + * @ 2026.06.19 [2026년 컨트리뷰션] 문자열 기반 설정 제거 + * @ 2026.06.25 [2026년 컨트리뷰션] 생성자 주입으로 변경 + * @ 2026.07.04 정찬영 [2026년 컨트리뷰션] 미사용 import 제거 및 @Slf4j로 로거 선언 통일 + * 2026.07.14 이백행 [2026년 컨트리뷰션] 불필요한 예외 제거 * * @author 개발프레임웍크 실행환경 개발팀 * @since 2009. 03.16 @@ -77,10 +78,9 @@ public void insertSample(SampleVO vo) throws Exception { * 글을 수정한다. * @param vo - 수정할 정보가 담긴 SampleVO * @return void형 - * @exception Exception */ @Override - public void updateSample(SampleVO vo) throws Exception { + public void updateSample(SampleVO vo) { sampleMapper.updateSample(vo); } @@ -88,10 +88,9 @@ public void updateSample(SampleVO vo) throws Exception { * 글을 삭제한다. * @param vo - 삭제할 정보가 담긴 SampleVO * @return void형 - * @exception Exception */ @Override - public void deleteSample(SampleVO vo) throws Exception { + public void deleteSample(SampleVO vo) { sampleMapper.deleteSample(vo); } @@ -113,10 +112,9 @@ public SampleVO selectSample(SampleVO vo) throws Exception { * 글 목록을 조회한다. * @param vo - 조회할 정보가 담긴 VO * @return 글 목록 - * @exception Exception */ @Override - public List selectSampleList(SampleVO vo) throws Exception { + public List selectSampleList(SampleVO vo) { return sampleMapper.selectSampleList(vo); } @@ -124,7 +122,6 @@ public List selectSampleList(SampleVO vo) throws Exception { * 글 총 갯수를 조회한다. * @param vo - 조회할 정보가 담긴 VO * @return 글 총 갯수 - * @exception */ @Override public int selectSampleListTotCnt(SampleVO vo) { diff --git a/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java b/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java index d28a7c8..97fb4ea 100644 --- a/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java +++ b/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java @@ -32,8 +32,9 @@ * * 수정일 수정자 수정내용 * ---------------- ------------ --------------------------- - * 2014.01.24 표준프레임워크센터 최초 생성 - * 2026.06.19 이백행 [2026년 컨트리뷰션] 문자열 기반 설정 제거 + * 2014.01.24 표준프레임워크센터 최초 생성 + * 2026.06.19 이백행 [2026년 컨트리뷰션] 문자열 기반 설정 제거 + * 2026.07.14 이백행 [2026년 컨트리뷰션] 불필요한 예외 제거 * * */ @@ -44,47 +45,41 @@ public interface SampleMapper { * 글을 등록한다. * @param vo - 등록할 정보가 담긴 SampleVO * @return 등록 결과 - * @exception Exception */ - void insertSample(SampleVO vo) throws Exception; + void insertSample(SampleVO vo); /** * 글을 수정한다. * @param vo - 수정할 정보가 담긴 SampleVO * @return void형 - * @exception Exception */ - void updateSample(SampleVO vo) throws Exception; + void updateSample(SampleVO vo); /** * 글을 삭제한다. * @param vo - 삭제할 정보가 담긴 SampleVO * @return void형 - * @exception Exception */ - void deleteSample(SampleVO vo) throws Exception; + void deleteSample(SampleVO vo); /** * 글을 조회한다. * @param vo - 조회할 정보가 담긴 SampleVO * @return 조회한 글 - * @exception Exception */ - SampleVO selectSample(SampleVO vo) throws Exception; + SampleVO selectSample(SampleVO vo); /** * 글 목록을 조회한다. * @param vo - 조회할 정보가 담긴 VO * @return 글 목록 - * @exception Exception */ - List selectSampleList(SampleVO vo) throws Exception; + List selectSampleList(SampleVO vo); /** * 글 총 갯수를 조회한다. * @param vo - 조회할 정보가 담긴 VO * @return 글 총 갯수 - * @exception */ 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 dd3f8b1..86e6dc8 100644 --- a/src/main/java/egovframework/example/sample/web/EgovSampleController.java +++ b/src/main/java/egovframework/example/sample/web/EgovSampleController.java @@ -42,8 +42,9 @@ * @ * @ 수정일 수정자 수정내용 * @ --------- --------- ------------------------------- - * @ 2009.03.16 최초생성 - * @ 2026.07.01 [2026년 컨트리뷰션] 불필요한 import 및 ModelAttribute name 속성 제거 + * @ 2009.03.16 최초생성 + * @ 2026.07.01 [2026년 컨트리뷰션] 불필요한 import 및 ModelAttribute name 속성 제거 + * 2026.07.14 이백행 [2026년 컨트리뷰션] 불필요한 예외 제거 * * @author 개발프레임웍크 실행환경 개발팀 * @since 2009. 03.16 @@ -65,7 +66,7 @@ public class EgovSampleController { private final EgovPropertyService propertiesService; @GetMapping("/") - public String index(@ModelAttribute SampleVO sampleVO, ModelMap model) throws Exception { + public String index(@ModelAttribute SampleVO sampleVO, ModelMap model) { return this.selectSampleList(sampleVO, model); } @@ -74,10 +75,9 @@ public String index(@ModelAttribute SampleVO sampleVO, ModelMap model) throws Ex * @param sampleVO - 조회할 정보가 담긴 SampleDefaultVO * @param model * @return "egovSampleList" - * @exception Exception */ @GetMapping("/egovSampleList.do") - public String selectSampleList(@ModelAttribute SampleVO sampleVO, ModelMap model) throws Exception { + public String selectSampleList(@ModelAttribute SampleVO sampleVO, ModelMap model) { /** EgovPropertyService.sample */ sampleVO.setPageUnit(propertiesService.getInt("pageUnit")); @@ -112,10 +112,9 @@ public String selectSampleList(@ModelAttribute SampleVO sampleVO, ModelMap model * @param sampleVO - 목록 조회조건 정보가 담긴 VO * @param model * @return "egovSampleRegister" - * @exception Exception */ @PostMapping("/addSampleView.do") - public String addSampleView( @ModelAttribute SampleVO sampleVO, Model model) throws Exception { + public String addSampleView( @ModelAttribute SampleVO sampleVO, Model model) { model.addAttribute("sampleVO", sampleVO); @@ -168,11 +167,10 @@ public String updateSampleView(@ModelAttribute SampleVO sampleVO, Model model) t * @param sampleVO - 수정할 정보가 담긴 VO * @param status * @return "forward:/egovSampleList.do" - * @exception Exception */ @PostMapping("/updateSample.do") public String updateSample(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindingResult, - Model model, RedirectAttributes redirectAttributes, SessionStatus status) throws Exception { + Model model, RedirectAttributes redirectAttributes, SessionStatus status) { if (bindingResult.hasErrors()) { model.addAttribute("sampleVO", sampleVO); @@ -194,10 +192,9 @@ public String updateSample(@Valid @ModelAttribute SampleVO sampleVO, BindingResu * @param sampleVO - 삭제할 정보가 담긴 VO * @param status * @return "forward:/egovSampleList.do" - * @exception Exception */ @PostMapping("/deleteSample.do") - public String deleteSample(@ModelAttribute SampleVO sampleVO, RedirectAttributes redirectAttributes, SessionStatus status) throws Exception { + public String deleteSample(@ModelAttribute SampleVO sampleVO, RedirectAttributes redirectAttributes, SessionStatus status) { sampleService.deleteSample(sampleVO); status.setComplete(); 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..0376076 100644 --- a/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTest.java @@ -72,7 +72,7 @@ void setUp() { @Test @DisplayName("글 수정 - 정상적으로 updateSample을 호출한다") - void updateSample_정상() throws Exception { + void updateSample_정상() { // given doNothing().when(sampleMapper).updateSample(sampleVO); @@ -85,7 +85,7 @@ void setUp() { @Test @DisplayName("글 삭제 - 정상적으로 deleteSample을 호출한다") - void deleteSample_정상() throws Exception { + void deleteSample_정상() { // given doNothing().when(sampleMapper).deleteSample(sampleVO); @@ -116,7 +116,7 @@ void setUp() { @Test @DisplayName("글 단건 조회 - 데이터가 없으면 예외가 발생한다") - void selectSample_데이터없음_예외() throws Exception { + void selectSample_데이터없음_예외() { // given when(sampleMapper.selectSample(sampleVO)).thenReturn(null); @@ -127,7 +127,7 @@ void setUp() { @Test @DisplayName("글 목록 조회 - 목록을 정상적으로 반환한다") @SuppressWarnings("unchecked") - void selectSampleList_정상() throws Exception { + void selectSampleList_정상() { // given SampleVO item1 = new SampleVO(); item1.setId("SAMPLE-001"); From f7f6d5028badfdb141086c4ea9eba58e9adf3fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=B0=B1=ED=96=89?= Date: Wed, 15 Jul 2026 08:07:24 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor(src/test):=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=98=88=EC=99=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EgovAopExceptionTransferTest.java | 19 +++++++++++-------- .../impl/EgovSampleServiceImplTest.java | 5 +++-- ...SampleServiceImplTestInsertSampleTest.java | 9 +++++---- .../SampleMapperTestDeleteSampleTest.java | 5 +++-- .../SampleMapperTestInsertSampleTest.java | 7 ++++--- .../SampleMapperTestSelectSampleListTest.java | 5 +++-- ...eMapperTestSelectSampleListTotCntTest.java | 5 +++-- .../SampleMapperTestUpdateSampleTest.java | 5 +++-- .../web/EgovSampleControllerTestAddTest.java | 11 ++++++----- .../EgovSampleControllerTestDeleteTest.java | 9 +++++---- ...govSampleControllerTestSelectListTest.java | 19 ++++++++++--------- .../web/EgovSampleControllerTestSelenium.java | 3 ++- .../EgovSampleControllerTestUpdateTest.java | 11 ++++++----- 13 files changed, 64 insertions(+), 49 deletions(-) diff --git a/src/test/java/egovframework/example/exception/EgovAopExceptionTransferTest.java b/src/test/java/egovframework/example/exception/EgovAopExceptionTransferTest.java index ef7d7f0..3672a9c 100644 --- a/src/test/java/egovframework/example/exception/EgovAopExceptionTransferTest.java +++ b/src/test/java/egovframework/example/exception/EgovAopExceptionTransferTest.java @@ -1,5 +1,6 @@ package egovframework.example.exception; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -31,27 +32,29 @@ void setUp() { @Test @DisplayName("doAfterThrowingExceptionTransferService - ExceptionTransfer.transfer 위임 확인") - void testDoAfterThrowingDelegatesToExceptionTransfer() throws Exception { + void testDoAfterThrowingDelegatesToExceptionTransfer() { JoinPoint joinPoint = mock(JoinPoint.class); Exception ex = new RuntimeException("서비스 예외"); - exceptionTransfer.doAfterThrowingExceptionTransferService(joinPoint, ex); - - verify(mockExceptionTransfer).transfer(eq(joinPoint), eq(ex)); + assertDoesNotThrow(() -> { + exceptionTransfer.doAfterThrowingExceptionTransferService(joinPoint, ex); + verify(mockExceptionTransfer).transfer(eq(joinPoint), eq(ex)); + }); } @Test @DisplayName("setExceptionTransfer - 의존성 주입 후 transfer 호출 가능") - void testSetExceptionTransfer() throws Exception { + void testSetExceptionTransfer() { ExceptionTransfer another = mock(ExceptionTransfer.class); exceptionTransfer.setExceptionTransfer(another); JoinPoint joinPoint = mock(JoinPoint.class); Exception ex = new IllegalStateException("상태 예외"); - exceptionTransfer.doAfterThrowingExceptionTransferService(joinPoint, ex); - - verify(another).transfer(any(JoinPoint.class), eq(ex)); + assertDoesNotThrow(() -> { + exceptionTransfer.doAfterThrowingExceptionTransferService(joinPoint, ex); + verify(another).transfer(any(JoinPoint.class), eq(ex)); + }); } } 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 0376076..424c4cc 100644 --- a/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTest.java @@ -16,6 +16,7 @@ package egovframework.example.sample.service.impl; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.doNothing; @@ -98,7 +99,7 @@ void setUp() { @Test @DisplayName("글 단건 조회 - 존재하는 글을 정상적으로 반환한다") - void selectSample_정상() throws Exception { + void selectSample_정상() { // given SampleVO expected = new SampleVO(); expected.setId("SAMPLE-001"); @@ -106,7 +107,7 @@ void setUp() { when(sampleMapper.selectSample(sampleVO)).thenReturn(expected); // when - SampleVO result = sut.selectSample(sampleVO); + SampleVO result = assertDoesNotThrow(() -> sut.selectSample(sampleVO)); // then assertNotNull(result); 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..fac4728 100644 --- a/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java @@ -1,6 +1,7 @@ package egovframework.example.sample.service.impl; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.time.LocalDateTime; @@ -34,7 +35,7 @@ class EgovSampleServiceImplTestInsertSampleTest { private EgovSampleService egovSampleService; @Test - void test() throws Exception { + void test() { // given final SampleVO sampleVO = new SampleVO(); @@ -54,10 +55,10 @@ void test() throws Exception { sampleVO.setRegUser("eGov"); // when - egovSampleService.insertSample(sampleVO); + assertDoesNotThrow(() -> egovSampleService.insertSample(sampleVO)); // then - final SampleVO resultSampleVO = egovSampleService.selectSample(sampleVO); + final SampleVO resultSampleVO = assertDoesNotThrow(() -> egovSampleService.selectSample(sampleVO)); if (log.isDebugEnabled()) { log.debug("sampleVO={}", sampleVO); @@ -81,4 +82,4 @@ private void asserts(final SampleVO sampleVO, final SampleVO resultSampleVO) { assertEquals(sampleVO.getRegUser(), resultSampleVO.getRegUser(), "글을 등록한다. 등록자"); } -} \ No newline at end of file +} diff --git a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestDeleteSampleTest.java b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestDeleteSampleTest.java index 1ad2009..a981c65 100644 --- a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestDeleteSampleTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestDeleteSampleTest.java @@ -1,6 +1,7 @@ package egovframework.example.sample.service.impl; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.time.LocalDateTime; @@ -32,10 +33,10 @@ class SampleMapperTestDeleteSampleTest { private EgovIdGnrService egovIdGnrService; @Test - void test() throws Exception { + void test() { // given final SampleVO sampleVO = new SampleVO(); - sampleVO.setId(egovIdGnrService.getNextStringId()); + sampleVO.setId(assertDoesNotThrow(() -> egovIdGnrService.getNextStringId())); final String now = LocalDateTime.now().toString(); diff --git a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestInsertSampleTest.java b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestInsertSampleTest.java index d847a43..684fa1d 100644 --- a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestInsertSampleTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestInsertSampleTest.java @@ -1,6 +1,7 @@ package egovframework.example.sample.service.impl; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.time.LocalDateTime; @@ -40,10 +41,10 @@ class SampleMapperTestInsertSampleTest { private EgovIdGnrService egovIdGnrService; @Test - void test() throws Exception { + void test() { // given final SampleVO sampleVO = new SampleVO(); - sampleVO.setId(egovIdGnrService.getNextStringId()); + sampleVO.setId(assertDoesNotThrow(() -> egovIdGnrService.getNextStringId())); final String now = LocalDateTime.now().toString(); // final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS")); @@ -88,4 +89,4 @@ private void asserts(final SampleVO sampleVO, final SampleVO resultSampleVO) { assertEquals(sampleVO.getRegUser(), resultSampleVO.getRegUser(), "글을 등록한다. 등록자"); } -} \ No newline at end of file +} diff --git a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestSelectSampleListTest.java b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestSelectSampleListTest.java index 13b7b08..bb2278b 100644 --- a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestSelectSampleListTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestSelectSampleListTest.java @@ -1,6 +1,7 @@ package egovframework.example.sample.service.impl; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertNotNull; import java.time.LocalDateTime; @@ -34,10 +35,10 @@ class SampleMapperTestSelectSampleListTest { private EgovIdGnrService egovIdGnrService; @Test - void test() throws Exception { + void test() { // given final SampleVO sampleVO = new SampleVO(); - sampleVO.setId(egovIdGnrService.getNextStringId()); + sampleVO.setId(assertDoesNotThrow(() -> egovIdGnrService.getNextStringId())); final String now = LocalDateTime.now().toString(); diff --git a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestSelectSampleListTotCntTest.java b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestSelectSampleListTotCntTest.java index 40c84b1..b066d46 100644 --- a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestSelectSampleListTotCntTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestSelectSampleListTotCntTest.java @@ -1,6 +1,7 @@ package egovframework.example.sample.service.impl; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.time.LocalDateTime; @@ -32,10 +33,10 @@ class SampleMapperTestSelectSampleListTotCntTest { private EgovIdGnrService egovIdGnrService; @Test - void test() throws Exception { + void test() { // given final SampleVO sampleVO = new SampleVO(); - sampleVO.setId(egovIdGnrService.getNextStringId()); + sampleVO.setId(assertDoesNotThrow(() -> egovIdGnrService.getNextStringId())); final String now = LocalDateTime.now().toString(); diff --git a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestUpdateSampleTest.java b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestUpdateSampleTest.java index bd11246..1ed2e82 100644 --- a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestUpdateSampleTest.java +++ b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestUpdateSampleTest.java @@ -1,6 +1,7 @@ package egovframework.example.sample.service.impl; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.time.LocalDateTime; @@ -32,10 +33,10 @@ class SampleMapperTestUpdateSampleTest { private EgovIdGnrService egovIdGnrService; @Test - void test() throws Exception { + void test() { // given final SampleVO sampleVO = new SampleVO(); - sampleVO.setId(egovIdGnrService.getNextStringId()); + sampleVO.setId(assertDoesNotThrow(() -> egovIdGnrService.getNextStringId())); final String now = LocalDateTime.now().toString(); diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java index d9bc5cd..7e1e359 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java @@ -1,6 +1,7 @@ package egovframework.example.sample.web; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; @@ -44,7 +45,7 @@ class EgovSampleControllerTestAddTest { private EgovSampleService egovSampleService; @Test - void test() throws Exception { + void test() { // given final SampleVO sampleVO = new SampleVO(); @@ -64,9 +65,9 @@ void test() throws Exception { sampleVO.setRegUser("eGov"); // when - mockMvc.perform( + assertDoesNotThrow(() -> mockMvc.perform( - post("/sample/add") + post("/addSample.do") .param("name", sampleVO.getName()) @@ -76,7 +77,7 @@ void test() throws Exception { .param("regUser", sampleVO.getRegUser()) - ).andDo(print()); + ).andDo(print())); // then sampleVO.setRecordCountPerPage(10); @@ -113,4 +114,4 @@ private void asserts(final SampleVO sampleVO, final SampleVO resultSampleVO) { assertEquals(sampleVO.getRegUser(), resultSampleVO.getRegUser(), "글을 등록한다. 등록자"); } -} \ No newline at end of file +} diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestDeleteTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestDeleteTest.java index 79bdadc..9649ed7 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestDeleteTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestDeleteTest.java @@ -16,6 +16,7 @@ package egovframework.example.sample.web; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrlPattern; @@ -55,7 +56,7 @@ class EgovSampleControllerTestDeleteTest { private EgovSampleService egovSampleService; @Test - void test() throws Exception { + void test() { // given - 등록 final SampleVO insertVO = new SampleVO(); final String now = LocalDateTime.now().toString(); @@ -63,7 +64,7 @@ void test() throws Exception { insertVO.setDescription("test 삭제대상 설명 " + now); insertVO.setUseYn("Y"); insertVO.setRegUser("eGov"); - egovSampleService.insertSample(insertVO); + assertDoesNotThrow(() -> egovSampleService.insertSample(insertVO)); insertVO.setRecordCountPerPage(10); insertVO.setFirstIndex(0); @@ -74,13 +75,13 @@ void test() throws Exception { final String insertedId = (String) insertedRow.get("id"); // when - mockMvc.perform( + assertDoesNotThrow(() -> mockMvc.perform( post("/deleteSample.do") .param("id", insertedId) ) .andDo(print()) .andExpect(status().is3xxRedirection()) - .andExpect(redirectedUrlPattern("/egovSampleList.do*")); + .andExpect(redirectedUrlPattern("/egovSampleList.do*"))); // then - 삭제 후 조회 시 예외 발생 if (log.isDebugEnabled()) { diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelectListTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelectListTest.java index b9590a4..f6bb483 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelectListTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelectListTest.java @@ -15,6 +15,7 @@ */ package egovframework.example.sample.web; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; @@ -46,18 +47,18 @@ class EgovSampleControllerTestSelectListTest { private MockMvc mockMvc; @Test - void test_목록조회_기본() throws Exception { - mockMvc.perform(get("/egovSampleList.do")) + void test_목록조회_기본() { + assertDoesNotThrow(() -> mockMvc.perform(get("/egovSampleList.do")) .andDo(print()) .andExpect(status().isOk()) .andExpect(view().name("sample/egovSampleList")) .andExpect(model().attributeExists("resultList")) - .andExpect(model().attributeExists("paginationInfo")); + .andExpect(model().attributeExists("paginationInfo"))); } @Test - void test_목록조회_검색조건_이름() throws Exception { - mockMvc.perform( + void test_목록조회_검색조건_이름() { + assertDoesNotThrow(() -> mockMvc.perform( get("/egovSampleList.do") .param("searchCondition", "1") .param("searchKeyword", "테스트") @@ -67,15 +68,15 @@ class EgovSampleControllerTestSelectListTest { .andExpect(status().isOk()) .andExpect(view().name("sample/egovSampleList")) .andExpect(model().attributeExists("resultList")) - .andExpect(model().attributeExists("paginationInfo")); + .andExpect(model().attributeExists("paginationInfo"))); } @Test - void test_인덱스_리다이렉트() throws Exception { - mockMvc.perform(get("/")) + void test_인덱스_리다이렉트() { + assertDoesNotThrow(() -> mockMvc.perform(get("/")) .andDo(print()) .andExpect(status().isOk()) - .andExpect(view().name("sample/egovSampleList")); + .andExpect(view().name("sample/egovSampleList"))); } } diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelenium.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelenium.java index 8553b82..c21fc0b 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelenium.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelenium.java @@ -53,7 +53,8 @@ void test() { sleep(); WebElement regUser = driver.findElement(By.id("regUser")); - regUser.sendKeys("test 이백행 등록자 " + now); +// regUser.sendKeys("test 이백행 등록자 " + now); + regUser.sendKeys("test 이백행"); sleep(); javascriptExecutor.executeScript("sampleAdd();"); diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestUpdateTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestUpdateTest.java index bb62d83..298d9f6 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestUpdateTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestUpdateTest.java @@ -16,6 +16,7 @@ package egovframework.example.sample.web; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrlPattern; @@ -55,7 +56,7 @@ class EgovSampleControllerTestUpdateTest { private EgovSampleService egovSampleService; @Test - void test() throws Exception { + void test() { // given - 등록 final SampleVO insertVO = new SampleVO(); final String now = LocalDateTime.now().toString(); @@ -63,7 +64,7 @@ void test() throws Exception { insertVO.setDescription("test 수정전 설명 " + now); insertVO.setUseYn("Y"); insertVO.setRegUser("eGov"); - egovSampleService.insertSample(insertVO); + assertDoesNotThrow(() -> egovSampleService.insertSample(insertVO)); insertVO.setRecordCountPerPage(10); insertVO.setFirstIndex(0); @@ -77,7 +78,7 @@ void test() throws Exception { final String updatedDescription = "test 수정후 설명 " + now; // when - mockMvc.perform( + assertDoesNotThrow(() -> mockMvc.perform( post("/updateSample.do") .param("id", insertedId) .param("name", updatedName) @@ -87,12 +88,12 @@ void test() throws Exception { ) .andDo(print()) .andExpect(status().is3xxRedirection()) - .andExpect(redirectedUrlPattern("/egovSampleList.do*")); + .andExpect(redirectedUrlPattern("/egovSampleList.do*"))); // then final SampleVO queryVO = new SampleVO(); queryVO.setId(insertedId); - final SampleVO result = egovSampleService.selectSample(queryVO); + final SampleVO result = assertDoesNotThrow(() -> egovSampleService.selectSample(queryVO)); if (log.isDebugEnabled()) { log.debug("insertedId={}", insertedId);