Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -37,7 +37,6 @@ import org.springframework.test.context.TestPropertySource;
|
|||||||
@ActiveProfiles(profiles = "test")
|
@ActiveProfiles(profiles = "test")
|
||||||
class MenuApiControllerTest {
|
class MenuApiControllerTest {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TestRestTemplate restTemplate;
|
private TestRestTemplate restTemplate;
|
||||||
|
|
||||||
@@ -85,7 +84,7 @@ class MenuApiControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//when
|
//when
|
||||||
ResponseEntity<List<MenuTreeResponseDto>> responseEntity = restTemplate.exchange("/api/v1/"+site.getId()+"/menus", HttpMethod.GET, null, new ParameterizedTypeReference<List<MenuTreeResponseDto>>(){});
|
ResponseEntity<List<MenuTreeResponseDto>> responseEntity = restTemplate.exchange("/api/v1/menus/"+site.getId()+"/tree", HttpMethod.GET, null, new ParameterizedTypeReference<List<MenuTreeResponseDto>>(){});
|
||||||
|
|
||||||
//then
|
//then
|
||||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@@ -198,17 +197,18 @@ class MenuApiControllerTest {
|
|||||||
|
|
||||||
Menu parentMenu = menuRepository.save(Menu.builder()
|
Menu parentMenu = menuRepository.save(Menu.builder()
|
||||||
.menuKorName("parent")
|
.menuKorName("parent")
|
||||||
|
.menuKorName("parenteng")
|
||||||
.sortSeq(1)
|
.sortSeq(1)
|
||||||
.site(site)
|
.site(site)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
//when
|
//when
|
||||||
String url = "/api/v1/manager/menus/"+parentMenu.getId();
|
String url = "/api/v1/menus/"+parentMenu.getId();
|
||||||
ResponseEntity<MenuResponseDto> responseEntity = restTemplate.getForEntity(url, MenuResponseDto.class);
|
ResponseEntity<MenuResponseDto> responseEntity = restTemplate.getForEntity(url, MenuResponseDto.class);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(responseEntity.getBody()).extracting("name").isEqualTo(parentMenu.getMenuKorName());
|
assertThat(responseEntity.getBody()).extracting("menuKorName").isEqualTo(parentMenu.getMenuKorName());
|
||||||
System.out.println(responseEntity.getBody());
|
System.out.println(responseEntity.getBody());
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -237,11 +237,6 @@ class MenuApiControllerTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @TODO
|
|
||||||
* bulk update 수정 필요
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void 메뉴관리_트리_드래그앤드랍_순서_및_부모메뉴_변경() throws Exception {
|
public void 메뉴관리_트리_드래그앤드랍_순서_및_부모메뉴_변경() throws Exception {
|
||||||
//given
|
//given
|
||||||
@@ -287,12 +282,11 @@ class MenuApiControllerTest {
|
|||||||
String url = "/api/v1/menus/"+site.getId()+"/tree";
|
String url = "/api/v1/menus/"+site.getId()+"/tree";
|
||||||
|
|
||||||
//when
|
//when
|
||||||
ResponseEntity<List<MenuTreeResponseDto>> responseEntity =
|
ResponseEntity<Long> responseEntity =
|
||||||
restTemplate.exchange(url, HttpMethod.PUT, httpEntity, new ParameterizedTypeReference<List<MenuTreeResponseDto>>(){});
|
restTemplate.exchange(url, HttpMethod.PUT, httpEntity, Long.class);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
responseEntity.getBody().stream().forEach(System.out::println);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.egovframe.cloud.portalservice.domain.menu.MenuRole;
|
|||||||
import org.egovframe.cloud.portalservice.domain.menu.MenuRoleRepository;
|
import org.egovframe.cloud.portalservice.domain.menu.MenuRoleRepository;
|
||||||
import org.egovframe.cloud.portalservice.domain.menu.Site;
|
import org.egovframe.cloud.portalservice.domain.menu.Site;
|
||||||
import org.egovframe.cloud.portalservice.domain.menu.SiteRepository;
|
import org.egovframe.cloud.portalservice.domain.menu.SiteRepository;
|
||||||
|
import org.egovframe.cloud.portalservice.domain.user.Role;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -36,7 +37,6 @@ import org.springframework.test.context.TestPropertySource;
|
|||||||
@ActiveProfiles(profiles = "test")
|
@ActiveProfiles(profiles = "test")
|
||||||
class MenuRoleApiControllerTest {
|
class MenuRoleApiControllerTest {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TestRestTemplate restTemplate;
|
private TestRestTemplate restTemplate;
|
||||||
|
|
||||||
@@ -108,8 +108,11 @@ class MenuRoleApiControllerTest {
|
|||||||
Menu child1 = menus.stream().filter(menu -> menu.getMenuKorName().equals("child_1")).collect(Collectors.toList()).get(0);
|
Menu child1 = menus.stream().filter(menu -> menu.getMenuKorName().equals("child_1")).collect(Collectors.toList()).get(0);
|
||||||
|
|
||||||
List<MenuRole> menuRoles = new ArrayList<>();
|
List<MenuRole> menuRoles = new ArrayList<>();
|
||||||
menuRoles.add(MenuRole.builder().roleId("role").menu(parent).build());
|
MenuRole menuRole1 = MenuRole.builder().roleId("ROLE").menu(parent).build();
|
||||||
menuRoles.add(MenuRole.builder().roleId("role").menu(child1).build());
|
menuRoles.add(menuRole1);
|
||||||
|
MenuRole menuRole2 = MenuRole.builder().roleId("ROLE").menu(child1).build();
|
||||||
|
menuRoles.add(menuRole2);
|
||||||
|
|
||||||
menuRoleRepository.saveAll(menuRoles);
|
menuRoleRepository.saveAll(menuRoles);
|
||||||
|
|
||||||
Site site = siteRepository.findAll().get(0);
|
Site site = siteRepository.findAll().get(0);
|
||||||
@@ -122,8 +125,8 @@ class MenuRoleApiControllerTest {
|
|||||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
List<MenuRoleResponseDto> body = responseEntity.getBody();
|
List<MenuRoleResponseDto> body = responseEntity.getBody();
|
||||||
assertThat(body.size()).isEqualTo(1);
|
assertThat(body.size()).isEqualTo(1);
|
||||||
assertThat(body.get(0).getIsChecked()).isTrue();
|
|
||||||
body.stream().forEach(System.out::println);
|
body.stream().forEach(System.out::println);
|
||||||
|
assertThat(body.get(0).getIsChecked()).isTrue();
|
||||||
assertThat(body.get(0).getChildren().size()).isEqualTo(3);
|
assertThat(body.get(0).getChildren().size()).isEqualTo(3);
|
||||||
body.stream().forEach(menuTreeResponseDto -> {
|
body.stream().forEach(menuTreeResponseDto -> {
|
||||||
menuTreeResponseDto.getChildren().stream().forEach(child -> {
|
menuTreeResponseDto.getChildren().stream().forEach(child -> {
|
||||||
@@ -151,7 +154,7 @@ class MenuRoleApiControllerTest {
|
|||||||
children.add(MenuRoleRequestDto.builder()
|
children.add(MenuRoleRequestDto.builder()
|
||||||
.menuRoleId(menuRoleResponseDto.getMenuRoleId())
|
.menuRoleId(menuRoleResponseDto.getMenuRoleId())
|
||||||
.isChecked(true)
|
.isChecked(true)
|
||||||
.roleId("role")
|
.roleId("ROLE")
|
||||||
.id(menuRoleResponseDto.getId())
|
.id(menuRoleResponseDto.getId())
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
@@ -159,7 +162,7 @@ class MenuRoleApiControllerTest {
|
|||||||
children.add(MenuRoleRequestDto.builder()
|
children.add(MenuRoleRequestDto.builder()
|
||||||
.menuRoleId(menuRoleResponseDto.getMenuRoleId())
|
.menuRoleId(menuRoleResponseDto.getMenuRoleId())
|
||||||
.isChecked(false)
|
.isChecked(false)
|
||||||
.roleId("role")
|
.roleId("ROLE")
|
||||||
.id(menuRoleResponseDto.getId())
|
.id(menuRoleResponseDto.getId())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
@@ -168,6 +171,7 @@ class MenuRoleApiControllerTest {
|
|||||||
requestDtoList.add(MenuRoleRequestDto.builder()
|
requestDtoList.add(MenuRoleRequestDto.builder()
|
||||||
.menuRoleId(list.get(0).getMenuRoleId())
|
.menuRoleId(list.get(0).getMenuRoleId())
|
||||||
.isChecked(true)
|
.isChecked(true)
|
||||||
|
.roleId("ROLE")
|
||||||
.id(list.get(0).getId())
|
.id(list.get(0).getId())
|
||||||
.children(children)
|
.children(children)
|
||||||
.build());
|
.build());
|
||||||
@@ -200,9 +204,10 @@ class MenuRoleApiControllerTest {
|
|||||||
.menuKorName("parent-any")
|
.menuKorName("parent-any")
|
||||||
.sortSeq(1)
|
.sortSeq(1)
|
||||||
.site(site)
|
.site(site)
|
||||||
|
.isUse(true)
|
||||||
.build());
|
.build());
|
||||||
MenuRole parentMenuRole = MenuRole.builder()
|
MenuRole parentMenuRole = MenuRole.builder()
|
||||||
.roleId("ROLE_ANONYMOUS")
|
.roleId(Role.ANONYMOUS.getKey())
|
||||||
.menu(parentMenu)
|
.menu(parentMenu)
|
||||||
.build();
|
.build();
|
||||||
parentMenuRole.setMenu(parentMenu);
|
parentMenuRole.setMenu(parentMenu);
|
||||||
@@ -214,11 +219,12 @@ class MenuRoleApiControllerTest {
|
|||||||
.site(site)
|
.site(site)
|
||||||
.parent(parentMenu)
|
.parent(parentMenu)
|
||||||
.sortSeq(i + 1)
|
.sortSeq(i + 1)
|
||||||
|
.isUse(true)
|
||||||
.build();
|
.build();
|
||||||
childMenu.setParentMenu(parentMenu);
|
childMenu.setParentMenu(parentMenu);
|
||||||
menuRepository.save(childMenu);
|
menuRepository.save(childMenu);
|
||||||
MenuRole role_any = MenuRole.builder()
|
MenuRole role_any = MenuRole.builder()
|
||||||
.roleId("ROLE_ANONYMOUS")
|
.roleId(Role.ANONYMOUS.getKey())
|
||||||
.menu(childMenu)
|
.menu(childMenu)
|
||||||
.build();
|
.build();
|
||||||
role_any.setMenu(childMenu);
|
role_any.setMenu(childMenu);
|
||||||
|
|||||||
@@ -88,10 +88,9 @@ class PolicyApiControllerTest {
|
|||||||
.contents(contents)
|
.contents(contents)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String url = "http://localhost:"+port+API_URL;
|
|
||||||
|
|
||||||
//when
|
//when
|
||||||
ResponseEntity<Long> responseEntity = restTemplate.postForEntity(url, requestDto, Long.class);
|
ResponseEntity<Long> responseEntity = restTemplate.postForEntity(API_URL, requestDto, Long.class);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@@ -104,7 +103,7 @@ class PolicyApiControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void 목록조회한다() throws Exception {
|
public void 목록조회한다() throws Exception {
|
||||||
|
|
||||||
String url = "http://localhost:"+port+API_URL+"?size=3%page=0";
|
String url = API_URL+"?size=3%page=0";
|
||||||
//when
|
//when
|
||||||
ResponseEntity<RestResponsePage<PolicyResponseDto>> responseEntity =
|
ResponseEntity<RestResponsePage<PolicyResponseDto>> responseEntity =
|
||||||
restTemplate.exchange(url, HttpMethod.GET, null, new ParameterizedTypeReference<RestResponsePage<PolicyResponseDto>>() {});
|
restTemplate.exchange(url, HttpMethod.GET, null, new ParameterizedTypeReference<RestResponsePage<PolicyResponseDto>>() {});
|
||||||
@@ -134,7 +133,7 @@ class PolicyApiControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void ID로_한건조회_정상() throws Exception {
|
public void ID로_한건조회_정상() throws Exception {
|
||||||
|
|
||||||
String url = "http://localhost:"+port+API_URL +"/9";
|
String url = API_URL +"/9";
|
||||||
|
|
||||||
//when
|
//when
|
||||||
ResponseEntity<PolicyResponseDto> responseEntity = restTemplate.getForEntity(url, PolicyResponseDto.class);
|
ResponseEntity<PolicyResponseDto> responseEntity = restTemplate.getForEntity(url, PolicyResponseDto.class);
|
||||||
@@ -153,7 +152,7 @@ class PolicyApiControllerTest {
|
|||||||
.contents("contents!!!!")
|
.contents("contents!!!!")
|
||||||
.build()
|
.build()
|
||||||
).getId();
|
).getId();
|
||||||
String url = "http://localhost:"+port+API_URL +"/"+id;
|
String url = API_URL +"/"+id;
|
||||||
|
|
||||||
PolicyUpdateRequestDto requestDto = PolicyUpdateRequestDto.builder()
|
PolicyUpdateRequestDto requestDto = PolicyUpdateRequestDto.builder()
|
||||||
.title("update title")
|
.title("update title")
|
||||||
@@ -183,7 +182,7 @@ class PolicyApiControllerTest {
|
|||||||
.contents("contents!!!!")
|
.contents("contents!!!!")
|
||||||
.build()
|
.build()
|
||||||
).getId();
|
).getId();
|
||||||
String url = "http://localhost:"+port+API_URL +"/"+id;
|
String url = API_URL +"/"+id;
|
||||||
|
|
||||||
//when
|
//when
|
||||||
restTemplate.delete(url);
|
restTemplate.delete(url);
|
||||||
@@ -203,7 +202,7 @@ class PolicyApiControllerTest {
|
|||||||
.contents("contents!!!")
|
.contents("contents!!!")
|
||||||
.build()
|
.build()
|
||||||
).getId();
|
).getId();
|
||||||
String url = "http://localhost:"+port+API_URL +"/"+id+"/"+false;
|
String url = API_URL +"/"+id+"/"+false;
|
||||||
|
|
||||||
//when
|
//when
|
||||||
ResponseEntity<Long> responseEntity = restTemplate.exchange(url, HttpMethod.PUT, null, Long.class);
|
ResponseEntity<Long> responseEntity = restTemplate.exchange(url, HttpMethod.PUT, null, Long.class);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.egovframe.cloud.portalservice.api.statistics;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.egovframe.cloud.portalservice.api.statistics.dto.StatisticsResponseDto;
|
import org.egovframe.cloud.portalservice.api.statistics.dto.StatisticsResponseDto;
|
||||||
@@ -33,7 +34,6 @@ class StatisticsApiControllerTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private StatisticsRepository statisticsRepository;
|
private StatisticsRepository statisticsRepository;
|
||||||
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
@@ -70,9 +70,11 @@ class StatisticsApiControllerTest {
|
|||||||
public void 일별접속통계_조회_성공() throws Exception {
|
public void 일별접속통계_조회_성공() throws Exception {
|
||||||
Long siteId = 1L;
|
Long siteId = 1L;
|
||||||
|
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
ResponseEntity< List<StatisticsResponseDto>> responseEntity =
|
ResponseEntity< List<StatisticsResponseDto>> responseEntity =
|
||||||
restTemplate.exchange("/api/v1/statistics/daily/"+siteId+"?year=2021&month=9",
|
restTemplate.exchange("/api/v1/statistics/daily/"+siteId+"?year="+now.getYear()+"&month="+now.getMonthValue(),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
null,
|
null,
|
||||||
new ParameterizedTypeReference<List<StatisticsResponseDto>>(){});
|
new ParameterizedTypeReference<List<StatisticsResponseDto>>(){});
|
||||||
|
|||||||
Reference in New Issue
Block a user