📝 swagger ui -> springdoc openapi ui 변경
This commit is contained in:
@@ -37,6 +37,7 @@ import org.springframework.test.context.TestPropertySource;
|
||||
@ActiveProfiles(profiles = "test")
|
||||
class MenuApiControllerTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@@ -50,9 +51,9 @@ class MenuApiControllerTest {
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
siteRepository.save(Site.builder()
|
||||
.name("site")
|
||||
.isUse(true)
|
||||
.build()
|
||||
.name("site")
|
||||
.isUse(true)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -67,18 +68,18 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
Menu parentMenu = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Menu childMenu = Menu.builder()
|
||||
.menuKorName("child_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
.menuKorName("child_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
childMenu.setParentMenu(parentMenu);
|
||||
menuRepository.save(childMenu);
|
||||
}
|
||||
@@ -101,14 +102,14 @@ class MenuApiControllerTest {
|
||||
public void 메뉴관리_사이트콤보_목록_조회한다() throws Exception {
|
||||
//given
|
||||
siteRepository.save(Site.builder()
|
||||
.name("portal")
|
||||
.isUse(true)
|
||||
.build()
|
||||
.name("portal")
|
||||
.isUse(true)
|
||||
.build()
|
||||
);
|
||||
siteRepository.save(Site.builder()
|
||||
.name("admin")
|
||||
.isUse(true)
|
||||
.build()
|
||||
.name("admin")
|
||||
.isUse(true)
|
||||
.build()
|
||||
);
|
||||
|
||||
//when
|
||||
@@ -126,50 +127,50 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
Menu parentMenu1 = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
Menu parentMenu2 = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent_2")
|
||||
.sortSeq(2)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent_2")
|
||||
.sortSeq(2)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Menu childMenu1 = Menu.builder()
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
childMenu1.setParentMenu(parentMenu1);
|
||||
menuRepository.save(childMenu1);
|
||||
if (i == 1) {
|
||||
Menu childChildMenu = Menu.builder()
|
||||
.menuKorName("child_child_1")
|
||||
.site(site)
|
||||
.parent(childMenu1)
|
||||
.sortSeq(1)
|
||||
.build();
|
||||
.menuKorName("child_child_1")
|
||||
.site(site)
|
||||
.parent(childMenu1)
|
||||
.sortSeq(1)
|
||||
.build();
|
||||
childChildMenu.setParentMenu(childMenu1);
|
||||
menuRepository.save(childChildMenu);
|
||||
Menu childChildMenu2 = Menu.builder()
|
||||
.menuKorName("child_child_1")
|
||||
.site(site)
|
||||
.parent(childMenu1)
|
||||
.sortSeq(2)
|
||||
.build();
|
||||
.menuKorName("child_child_1")
|
||||
.site(site)
|
||||
.parent(childMenu1)
|
||||
.sortSeq(2)
|
||||
.build();
|
||||
childChildMenu2.setParentMenu(childMenu1);
|
||||
menuRepository.save(childChildMenu2);
|
||||
}
|
||||
|
||||
Menu childMenu2 = Menu.builder()
|
||||
.menuKorName("child_2_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu2)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
.menuKorName("child_2_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu2)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
childMenu1.setParentMenu(parentMenu2);
|
||||
menuRepository.save(childMenu2);
|
||||
}
|
||||
@@ -196,11 +197,11 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
Menu parentMenu = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent")
|
||||
.menuKorName("parenteng")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent")
|
||||
.menuKorName("parenteng")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
//when
|
||||
String url = "/api/v1/menus/"+parentMenu.getId();
|
||||
@@ -219,11 +220,11 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
MenuTreeRequestDto menuTreeRequestDto = MenuTreeRequestDto.builder()
|
||||
.parentId(null)
|
||||
.siteId(site.getId())
|
||||
.name("parent")
|
||||
.sortSeq(1)
|
||||
.build();
|
||||
.parentId(null)
|
||||
.siteId(site.getId())
|
||||
.name("parent")
|
||||
.sortSeq(1)
|
||||
.build();
|
||||
|
||||
String url = "/api/v1/menus";
|
||||
|
||||
@@ -243,24 +244,24 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
Menu parentMenu1 = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
Menu parentMenu2 = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent_2")
|
||||
.sortSeq(2)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent_2")
|
||||
.sortSeq(2)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
Long menuId = 0L;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Menu childMenu1 = Menu.builder()
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
childMenu1.setParentMenu(parentMenu1);
|
||||
Menu save = menuRepository.save(childMenu1);
|
||||
menuId = save.getId();
|
||||
@@ -269,13 +270,13 @@ class MenuApiControllerTest {
|
||||
List<MenuDnDRequestDto> updateList = new ArrayList<>();
|
||||
|
||||
updateList.add(MenuDnDRequestDto.builder()
|
||||
.menuId(menuId)
|
||||
.sortSeq(1)
|
||||
.parentId(parentMenu2.getId())
|
||||
.build());
|
||||
.menuId(menuId)
|
||||
.sortSeq(1)
|
||||
.parentId(parentMenu2.getId())
|
||||
.build());
|
||||
|
||||
HttpEntity<List<MenuDnDRequestDto>> httpEntity = new HttpEntity<>(
|
||||
updateList
|
||||
updateList
|
||||
);
|
||||
|
||||
|
||||
@@ -283,7 +284,7 @@ class MenuApiControllerTest {
|
||||
|
||||
//when
|
||||
ResponseEntity<Long> responseEntity =
|
||||
restTemplate.exchange(url, HttpMethod.PUT, httpEntity, Long.class);
|
||||
restTemplate.exchange(url, HttpMethod.PUT, httpEntity, Long.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -295,19 +296,19 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
Menu parentMenu1 = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
Long menuId = 0L;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Menu childMenu1 = Menu.builder()
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
childMenu1.setParentMenu(parentMenu1);
|
||||
Menu save = menuRepository.save(childMenu1);
|
||||
menuId = save.getId();
|
||||
@@ -317,7 +318,7 @@ class MenuApiControllerTest {
|
||||
|
||||
//when
|
||||
ResponseEntity<MenuTreeResponseDto> responseEntity =
|
||||
restTemplate.exchange(url, HttpMethod.PUT, null, MenuTreeResponseDto.class);
|
||||
restTemplate.exchange(url, HttpMethod.PUT, null, MenuTreeResponseDto.class);
|
||||
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getBody().getName()).isEqualTo("updateName");
|
||||
@@ -330,31 +331,31 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
Menu parentMenu1 = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
String url = "/api/v1/menus/"+parentMenu1.getId();
|
||||
|
||||
|
||||
HttpEntity<MenuUpdateRequestDto> httpEntity = new HttpEntity<>(
|
||||
MenuUpdateRequestDto.builder()
|
||||
.description("상위메뉴")
|
||||
.connectId(1)
|
||||
.menuType("menuType")
|
||||
.urlPath("/index")
|
||||
.subName("subname")
|
||||
.isUse(true)
|
||||
.isShow(true)
|
||||
.isBlank(false)
|
||||
.icon("icon")
|
||||
MenuUpdateRequestDto.builder()
|
||||
.description("상위메뉴")
|
||||
.connectId(1)
|
||||
.menuType("menuType")
|
||||
.urlPath("/index")
|
||||
.subName("subname")
|
||||
.isUse(true)
|
||||
.isShow(true)
|
||||
.isBlank(false)
|
||||
.icon("icon")
|
||||
.build()
|
||||
);
|
||||
|
||||
//when
|
||||
ResponseEntity<MenuResponseDto> responseEntity =
|
||||
restTemplate.exchange(url, HttpMethod.PUT, httpEntity, MenuResponseDto.class);
|
||||
restTemplate.exchange(url, HttpMethod.PUT, httpEntity, MenuResponseDto.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -369,19 +370,19 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
Menu parentMenu1 = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
Long menuId = 0L;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Menu childMenu1 = Menu.builder()
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
childMenu1.setParentMenu(parentMenu1);
|
||||
Menu save = menuRepository.save(childMenu1);
|
||||
menuId = save.getId();
|
||||
@@ -403,19 +404,19 @@ class MenuApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
|
||||
Menu parentMenu1 = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent_1")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
Long menuId = 0L;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Menu childMenu1 = Menu.builder()
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
.menuKorName("child_1_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu1)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
childMenu1.setParentMenu(parentMenu1);
|
||||
Menu save = menuRepository.save(childMenu1);
|
||||
menuId = save.getId();
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@EnableConfigurationProperties
|
||||
@@ -37,6 +38,7 @@ import org.springframework.test.context.TestPropertySource;
|
||||
@ActiveProfiles(profiles = "test")
|
||||
class MenuRoleApiControllerTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@@ -52,24 +54,24 @@ class MenuRoleApiControllerTest {
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
Site site = Site.builder()
|
||||
.name("site")
|
||||
.isUse(true)
|
||||
.build();
|
||||
.name("site")
|
||||
.isUse(true)
|
||||
.build();
|
||||
siteRepository.save(site);
|
||||
|
||||
Menu parentMenu = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
.menuKorName("parent")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.build());
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Menu childMenu = Menu.builder()
|
||||
.menuKorName("child_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
.menuKorName("child_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu)
|
||||
.sortSeq(i + 1)
|
||||
.build();
|
||||
childMenu.setParentMenu(parentMenu);
|
||||
menuRepository.save(childMenu);
|
||||
}
|
||||
@@ -87,7 +89,7 @@ class MenuRoleApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
//when
|
||||
ResponseEntity<List<MenuRoleResponseDto>> responseEntity =
|
||||
restTemplate.exchange("/api/v1/menu-roles/role/"+site.getId(), HttpMethod.GET, null, new ParameterizedTypeReference<List<MenuRoleResponseDto>>(){});
|
||||
restTemplate.exchange("/api/v1/menu-roles/role/"+site.getId(), HttpMethod.GET, null, new ParameterizedTypeReference<List<MenuRoleResponseDto>>(){});
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -118,7 +120,7 @@ class MenuRoleApiControllerTest {
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
//when
|
||||
ResponseEntity<List<MenuRoleResponseDto>> responseEntity =
|
||||
restTemplate.exchange("/api/v1/menu-roles/role/"+site.getId(), HttpMethod.GET, null, new ParameterizedTypeReference<List<MenuRoleResponseDto>>(){});
|
||||
restTemplate.exchange("/api/v1/menu-roles/role/"+site.getId(), HttpMethod.GET, null, new ParameterizedTypeReference<List<MenuRoleResponseDto>>(){});
|
||||
|
||||
|
||||
//then
|
||||
@@ -152,39 +154,39 @@ class MenuRoleApiControllerTest {
|
||||
list.get(0).getChildren().stream().forEach(menuRoleResponseDto -> {
|
||||
if (menuRoleResponseDto.getKorName().equals("child_1")) {
|
||||
children.add(MenuRoleRequestDto.builder()
|
||||
.menuRoleId(menuRoleResponseDto.getMenuRoleId())
|
||||
.isChecked(true)
|
||||
.roleId("ROLE")
|
||||
.id(menuRoleResponseDto.getId())
|
||||
.build());
|
||||
.menuRoleId(menuRoleResponseDto.getMenuRoleId())
|
||||
.isChecked(true)
|
||||
.roleId("ROLE")
|
||||
.id(menuRoleResponseDto.getId())
|
||||
.build());
|
||||
|
||||
}else {
|
||||
children.add(MenuRoleRequestDto.builder()
|
||||
.menuRoleId(menuRoleResponseDto.getMenuRoleId())
|
||||
.isChecked(false)
|
||||
.roleId("ROLE")
|
||||
.id(menuRoleResponseDto.getId())
|
||||
.build());
|
||||
.menuRoleId(menuRoleResponseDto.getMenuRoleId())
|
||||
.isChecked(false)
|
||||
.roleId("ROLE")
|
||||
.id(menuRoleResponseDto.getId())
|
||||
.build());
|
||||
}
|
||||
});
|
||||
|
||||
requestDtoList.add(MenuRoleRequestDto.builder()
|
||||
.menuRoleId(list.get(0).getMenuRoleId())
|
||||
.isChecked(true)
|
||||
.roleId("ROLE")
|
||||
.id(list.get(0).getId())
|
||||
.children(children)
|
||||
.build());
|
||||
.menuRoleId(list.get(0).getMenuRoleId())
|
||||
.isChecked(true)
|
||||
.roleId("ROLE")
|
||||
.id(list.get(0).getId())
|
||||
.children(children)
|
||||
.build());
|
||||
|
||||
HttpEntity<List<MenuRoleRequestDto>> httpEntity = new HttpEntity<>(
|
||||
requestDtoList
|
||||
requestDtoList
|
||||
);
|
||||
|
||||
|
||||
|
||||
//when
|
||||
ResponseEntity<String> responseEntity =
|
||||
restTemplate.exchange("/api/v1/menu-roles", HttpMethod.POST, httpEntity, String.class);
|
||||
restTemplate.exchange("/api/v1/menu-roles", HttpMethod.POST, httpEntity, String.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -201,38 +203,38 @@ class MenuRoleApiControllerTest {
|
||||
//given
|
||||
Site site = siteRepository.findAll().get(0);
|
||||
Menu parentMenu = menuRepository.save(Menu.builder()
|
||||
.menuKorName("parent-any")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.isUse(true)
|
||||
.build());
|
||||
.menuKorName("parent-any")
|
||||
.sortSeq(1)
|
||||
.site(site)
|
||||
.isUse(true)
|
||||
.build());
|
||||
MenuRole parentMenuRole = MenuRole.builder()
|
||||
.roleId(Role.ANONYMOUS.getKey())
|
||||
.menu(parentMenu)
|
||||
.build();
|
||||
.roleId(Role.ANONYMOUS.getKey())
|
||||
.menu(parentMenu)
|
||||
.build();
|
||||
parentMenuRole.setMenu(parentMenu);
|
||||
menuRoleRepository.save(parentMenuRole);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Menu childMenu = Menu.builder()
|
||||
.menuKorName("child-any_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu)
|
||||
.sortSeq(i + 1)
|
||||
.isUse(true)
|
||||
.build();
|
||||
.menuKorName("child-any_" + i)
|
||||
.site(site)
|
||||
.parent(parentMenu)
|
||||
.sortSeq(i + 1)
|
||||
.isUse(true)
|
||||
.build();
|
||||
childMenu.setParentMenu(parentMenu);
|
||||
menuRepository.save(childMenu);
|
||||
MenuRole role_any = MenuRole.builder()
|
||||
.roleId(Role.ANONYMOUS.getKey())
|
||||
.menu(childMenu)
|
||||
.build();
|
||||
.roleId(Role.ANONYMOUS.getKey())
|
||||
.menu(childMenu)
|
||||
.build();
|
||||
role_any.setMenu(childMenu);
|
||||
menuRoleRepository.save(role_any);
|
||||
}
|
||||
//when
|
||||
ResponseEntity<List<MenuSideResponseDto>> responseEntity =
|
||||
restTemplate.exchange("/api/v1/menu-roles/"+site.getId(), HttpMethod.GET, null, new ParameterizedTypeReference<List<MenuSideResponseDto>>(){});
|
||||
restTemplate.exchange("/api/v1/menu-roles/"+site.getId(), HttpMethod.GET, null, new ParameterizedTypeReference<List<MenuSideResponseDto>>(){});
|
||||
|
||||
|
||||
//then
|
||||
|
||||
@@ -59,12 +59,12 @@ class PolicyApiControllerTest {
|
||||
}
|
||||
|
||||
policyRepository.save(Policy.builder()
|
||||
.type(type)
|
||||
.title(title)
|
||||
.isUse(true)
|
||||
.regDate(ZonedDateTime.now())
|
||||
.contents(contents)
|
||||
.build());
|
||||
.type(type)
|
||||
.title(title)
|
||||
.isUse(true)
|
||||
.regDate(ZonedDateTime.now())
|
||||
.contents(contents)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ class PolicyApiControllerTest {
|
||||
String contents = "test contents";
|
||||
|
||||
PolicySaveRequestDto requestDto = PolicySaveRequestDto.builder()
|
||||
.type(type)
|
||||
.title(title)
|
||||
.isUse(true)
|
||||
.regDate(ZonedDateTime.now())
|
||||
.contents(contents)
|
||||
.build();
|
||||
.type(type)
|
||||
.title(title)
|
||||
.isUse(true)
|
||||
.regDate(ZonedDateTime.now())
|
||||
.contents(contents)
|
||||
.build();
|
||||
|
||||
|
||||
//when
|
||||
@@ -106,7 +106,7 @@ class PolicyApiControllerTest {
|
||||
String url = API_URL+"?size=3%page=0";
|
||||
//when
|
||||
ResponseEntity<RestResponsePage<PolicyResponseDto>> responseEntity =
|
||||
restTemplate.exchange(url, HttpMethod.GET, null, new ParameterizedTypeReference<RestResponsePage<PolicyResponseDto>>() {});
|
||||
restTemplate.exchange(url, HttpMethod.GET, null, new ParameterizedTypeReference<RestResponsePage<PolicyResponseDto>>() {});
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -147,17 +147,17 @@ class PolicyApiControllerTest {
|
||||
public void 이용약관_수정_된다() throws Exception {
|
||||
//given
|
||||
Long id = policyRepository.save(Policy.builder()
|
||||
.type("TOS")
|
||||
.title("title")
|
||||
.contents("contents!!!!")
|
||||
.build()
|
||||
.type("TOS")
|
||||
.title("title")
|
||||
.contents("contents!!!!")
|
||||
.build()
|
||||
).getId();
|
||||
String url = API_URL +"/"+id;
|
||||
|
||||
PolicyUpdateRequestDto requestDto = PolicyUpdateRequestDto.builder()
|
||||
.title("update title")
|
||||
.contents("update Details")
|
||||
.build();
|
||||
.title("update title")
|
||||
.contents("update Details")
|
||||
.build();
|
||||
|
||||
//when
|
||||
HttpEntity<PolicyUpdateRequestDto> requestEntity = new HttpEntity<>(requestDto);
|
||||
@@ -177,10 +177,10 @@ class PolicyApiControllerTest {
|
||||
public void 이용약관_삭제_한다() {
|
||||
//given
|
||||
Long id = policyRepository.save(Policy.builder()
|
||||
.type("TOS")
|
||||
.title("title")
|
||||
.contents("contents!!!!")
|
||||
.build()
|
||||
.type("TOS")
|
||||
.title("title")
|
||||
.contents("contents!!!!")
|
||||
.build()
|
||||
).getId();
|
||||
String url = API_URL +"/"+id;
|
||||
|
||||
@@ -196,11 +196,11 @@ class PolicyApiControllerTest {
|
||||
public void 사용여부_수정_한다() throws Exception {
|
||||
//given
|
||||
Long id = policyRepository.save(Policy.builder()
|
||||
.type("TOS")
|
||||
.title("title")
|
||||
.isUse(true)
|
||||
.contents("contents!!!")
|
||||
.build()
|
||||
.type("TOS")
|
||||
.title("title")
|
||||
.isUse(true)
|
||||
.contents("contents!!!")
|
||||
.build()
|
||||
).getId();
|
||||
String url = API_URL +"/"+id+"/"+false;
|
||||
|
||||
|
||||
@@ -5,12 +5,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.egovframe.cloud.portalservice.api.statistics.dto.StatisticsResponseDto;
|
||||
import org.egovframe.cloud.portalservice.domain.statistics.Statistics;
|
||||
import org.egovframe.cloud.portalservice.domain.statistics.StatisticsRepository;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -38,9 +41,9 @@ class StatisticsApiControllerTest {
|
||||
public void setup() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
statisticsRepository.save(Statistics.builder()
|
||||
.siteId(1L)
|
||||
.remoteIp("testip")
|
||||
.build());
|
||||
.siteId(1L)
|
||||
.remoteIp("testip")
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,10 +58,10 @@ class StatisticsApiControllerTest {
|
||||
Long siteId = 1L;
|
||||
// when
|
||||
ResponseEntity< List<StatisticsResponseDto>> responseEntity =
|
||||
restTemplate.exchange("/api/v1/statistics/monthly/"+siteId,
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<List<StatisticsResponseDto>>(){});
|
||||
restTemplate.exchange("/api/v1/statistics/monthly/"+siteId,
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<List<StatisticsResponseDto>>(){});
|
||||
|
||||
responseEntity.getBody().forEach(System.out::println);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -74,10 +77,10 @@ class StatisticsApiControllerTest {
|
||||
|
||||
// when
|
||||
ResponseEntity< List<StatisticsResponseDto>> responseEntity =
|
||||
restTemplate.exchange("/api/v1/statistics/daily/"+siteId+"?year="+now.getYear()+"&month="+now.getMonthValue(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<List<StatisticsResponseDto>>(){});
|
||||
restTemplate.exchange("/api/v1/statistics/daily/"+siteId+"?year="+now.getYear()+"&month="+now.getMonthValue(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<List<StatisticsResponseDto>>(){});
|
||||
|
||||
responseEntity.getBody().forEach(System.out::println);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -85,5 +88,4 @@ class StatisticsApiControllerTest {
|
||||
assertThat(responseEntity.getBody().get(0).getY()).isEqualTo(10);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user