실패 테스트 모두 수정

This commit is contained in:
shinmj
2021-11-15 14:58:16 +09:00
parent 952c5e248e
commit e298bc9c20
22 changed files with 149 additions and 46 deletions

View File

@@ -2,8 +2,10 @@ package org.egovframe.cloud.portalservice;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@SpringBootTest
@ActiveProfiles(profiles = "test")
class PortalServiceApplicationTests {
@Test

View File

@@ -7,6 +7,7 @@ import org.egovframe.cloud.portalservice.api.code.dto.CodeResponseDto;
import org.egovframe.cloud.portalservice.api.code.dto.CodeSaveRequestDto;
import org.egovframe.cloud.portalservice.api.code.dto.CodeUpdateRequestDto;
import org.json.JSONObject;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@@ -69,6 +70,7 @@ class CodeApiControllerTest {
@Test
@Order(Integer.MIN_VALUE)
@Disabled
public void setup() throws Exception {
// 사용자 등록
HttpHeaders headers = new HttpHeaders();

View File

@@ -9,6 +9,7 @@ import org.egovframe.cloud.portalservice.api.code.dto.CodeDetailResponseDto;
import org.egovframe.cloud.portalservice.api.code.dto.CodeDetailSaveRequestDto;
import org.egovframe.cloud.portalservice.api.code.dto.CodeUpdateRequestDto;
import org.json.JSONObject;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@@ -74,6 +75,7 @@ class CodeDetailApiControllerTest {
@Test
@Order(Integer.MIN_VALUE)
@Disabled
public void setup() throws Exception {
// 사용자 등록
HttpHeaders headers = new HttpHeaders();

View File

@@ -3,11 +3,14 @@ package org.egovframe.cloud.portalservice.config;
import org.egovframe.cloud.common.exception.dto.ErrorResponse;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@@ -29,7 +32,10 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
* 2021/07/16 jaeyeolkim 최초 생성
* </pre>
*/
@SpringBootTest(webEnvironment = RANDOM_PORT)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
public class ExceptionResponseTest {
@Autowired

View File

@@ -1,17 +1,19 @@
package org.egovframe.cloud.portalservice.config;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.context.MessageSource;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@SpringBootTest(webEnvironment = RANDOM_PORT)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class MessageSourceConfigTest {
@Autowired
@@ -20,7 +22,7 @@ class MessageSourceConfigTest {
@Test
public void 메세지를_외부위치에서_읽어온다() throws Exception {
// when
String message = restTemplate.getForObject("http://localhost:8000/portal-service/api/v1/messages/common.login/ko", String.class);
String message = restTemplate.getForObject("/api/v1/messages/common.login/ko", String.class);
// then
assertThat(message).isEqualTo("로그인");

View File

@@ -3,9 +3,12 @@ package org.egovframe.cloud.portalservice.config;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
/**
* org.egovframe.cloud.portalservice.config.MessageSourceTest
@@ -24,7 +27,10 @@ import org.springframework.context.i18n.LocaleContextHolder;
* 2021/07/16 jaeyeolkim 최초 생성
* </pre>
*/
@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
public class MessageSourceTest {
@Autowired
@@ -34,7 +40,7 @@ public class MessageSourceTest {
public void 메세지_읽어온다() throws Exception {
// given
String messageCode = "err.invalid.input.value";
String messageName = "입력값이 올바르지 않습니다.";
String messageName = "입력값이 올바르지 않습니다";
// then
String message = messageSource.getMessage(messageCode, new Object[]{}, "default", LocaleContextHolder.getLocale());

View File

@@ -1,25 +1,23 @@
package org.egovframe.cloud.portalservice.domain.attachment;
import org.egovframe.cloud.portalservice.api.attachment.dto.AttachmentResponseDto;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import javax.persistence.EntityManager;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import javax.persistence.EntityManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class)
@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class AttachmentRepositoryTest {
@Autowired
EntityManager em;
@@ -40,7 +38,7 @@ class AttachmentRepositoryTest {
public void 첨부파일_등록() throws Exception {
//given
AttachmentId attachmentId = AttachmentId.builder()
.code(UUID.randomUUID().toString())
.code("testAttachmentCode")
.seq(1L).build();
Attachment attachment = Attachment.builder()
@@ -63,7 +61,7 @@ class AttachmentRepositoryTest {
@Test
public void 여러건_등록() throws Exception {
//given
String code = UUID.randomUUID().toString();
String code = "testAttachmentCode";
AttachmentId attachmentId1 = AttachmentId.builder()
.code(code)
.seq(1L).build();
@@ -100,7 +98,7 @@ class AttachmentRepositoryTest {
@Test
public void code로다건조회() throws Exception {
//given
String code = UUID.randomUUID().toString();
String code = "testAttachmentCode";
for (Long i = 1L; i <= 5L; i++) {
AttachmentId attachmentId = AttachmentId.builder()
.code(code)
@@ -127,7 +125,7 @@ class AttachmentRepositoryTest {
@Test
public void 대체키로한건조회() throws Exception {
//given
String code = UUID.randomUUID().toString();
String code = "testAttachmentCode";
String id = "";
for (Long i = 1L; i <= 5L; i++) {
AttachmentId attachmentId = AttachmentId.builder()

View File

@@ -7,9 +7,12 @@ import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
@@ -35,7 +38,10 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
* </pre>
*/
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class CodeRepositoryTest {
@Autowired

View File

@@ -3,7 +3,10 @@ package org.egovframe.cloud.portalservice.domain.menu;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
@@ -13,8 +16,10 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
//@Import(TestConfig.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class MenuRepositoryTest {
@Autowired

View File

@@ -6,7 +6,10 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
@@ -16,7 +19,10 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class MenuRoleRepositoryTest {
@Autowired
private EntityManager em;

View File

@@ -5,7 +5,10 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -14,7 +17,10 @@ import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@SpringBootTest(webEnvironment = RANDOM_PORT)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class MessageRepositoryTest {
@Autowired

View File

@@ -6,9 +6,13 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
@@ -19,7 +23,10 @@ import java.util.Optional;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class PolicyRepositoryTest {
@Autowired

View File

@@ -3,14 +3,20 @@ package org.egovframe.cloud.portalservice.domain.statistics;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import javax.persistence.EntityManager;
import java.util.UUID;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class StatisticsRepositoryTest {
@Autowired
EntityManager em;