Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.List;

import org.egovframe.rte.fdl.cmmn.exception.BaseRuntimeException;

/**
* @Class Name : EgovSampleService.java
* @Description : EgovSampleService Class
Expand All @@ -38,9 +40,8 @@ public interface EgovSampleService {
* 글을 등록한다.
* @param vo - 등록할 정보가 담긴 SampleVO
* @return 등록 결과
* @exception Exception
*/
void insertSample(SampleVO vo) throws Exception;
void insertSample(SampleVO vo);

/**
* 글을 수정한다.
Expand All @@ -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;

/**
* 글 목록을 조회한다.
Expand All @@ -75,7 +77,6 @@ public interface EgovSampleService {
* 글 총 개수를 조회한다.
* @param vo - 조회할 정보가 담긴 VO
* @return 글 총 개수
* @exception
*/
int selectSampleListTotCnt(SampleVO vo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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;
}

Expand All @@ -119,7 +127,6 @@ public List<?> selectSampleList(SampleVO vo) {
* 글 총 개수를 조회한다.
* @param vo - 조회할 정보가 담긴 VO
* @return 글 총 개수
* @exception
*/
@Override
public int selectSampleListTotCnt(SampleVO vo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("서비스 예외");

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,7 +73,7 @@ void setUp() {

@Test
@DisplayName("글 수정 - 정상적으로 updateSample을 호출한다")
void updateSample_정상() throws Exception {
void updateSample_정상() {
// given
doNothing().when(sampleMapper).updateSample(sampleVO);

Expand All @@ -85,7 +86,7 @@ void setUp() {

@Test
@DisplayName("글 삭제 - 정상적으로 deleteSample을 호출한다")
void deleteSample_정상() throws Exception {
void deleteSample_정상() {
// given
doNothing().when(sampleMapper).deleteSample(sampleVO);

Expand All @@ -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");
Expand All @@ -116,7 +117,7 @@ void setUp() {

@Test
@DisplayName("글 단건 조회 - 데이터가 없으면 예외가 발생한다")
void selectSample_데이터없음_예외() throws Exception {
void selectSample_데이터없음_예외() {
// given
when(sampleMapper.selectSample(sampleVO)).thenReturn(null);

Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,7 +17,6 @@

import egovframework.example.sample.service.EgovSampleService;
import egovframework.example.sample.service.SampleVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
Expand All @@ -30,7 +30,6 @@
@SpringBootTest
@AutoConfigureMockMvc

@RequiredArgsConstructor
@Slf4j
class EgovSampleControllerTestAddTest {

Expand All @@ -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(
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand All @@ -56,7 +57,7 @@ class EgovSampleControllerTestSelectListTest {
}

@Test
void test_목록조회_검색조건_이름() throws Exception {
void test_목록조회_검색조건_이름() throws BaseRuntimeException, Exception {
mockMvc.perform(
get("/egovSampleList.do")
.param("searchCondition", "1")
Expand All @@ -71,7 +72,7 @@ class EgovSampleControllerTestSelectListTest {
}

@Test
void test_인덱스_리다이렉트() throws Exception {
void test_인덱스_리다이렉트() throws BaseRuntimeException, Exception {
mockMvc.perform(get("/"))
.andDo(print())
.andExpect(status().isOk())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down