Search in sources :

Example 1 with MenuDto

use of com.albedo.java.modules.sys.domain.dto.MenuDto in project albedo by somowhere.

the class MenuDoResourceIntTest method createEntity.

/**
 * Create a Menu.
 * <p>
 * This is a static method, as tests for other entities might also need it, if they
 * test an domain which has a required relationship to the Menu domain.
 */
public MenuDto createEntity() {
    MenuDto menu = new MenuDto();
    menu.setName(DEFAULT_NAME);
    menu.setComponent(DEFAULT_COMPONENT);
    menu.setIcon(DEFAULT_ICON);
    menu.setPermission(DEFAULT_PERMISSION);
    menu.setHidden(DEFAULT_HIDDEN);
    menu.setCache(DEFAULT_CACHE);
    menu.setIframe(DEFAULT_IFRAME);
    menu.setSort(DEFAULT_SORT);
    menu.setComponent(DEFAULT_COMPONENT);
    menu.setPath(DEFAULT_PATH);
    menu.setType(DEFAULT_TYPE);
    menu.setDescription(DEFAULT_DESCRIPTION);
    return menu;
}
Also used : MenuDto(com.albedo.java.modules.sys.domain.dto.MenuDto)

Example 2 with MenuDto

use of com.albedo.java.modules.sys.domain.dto.MenuDto in project albedo by somowhere.

the class MenuDoResourceIntTest method updateMenu.

@Test
@Transactional(rollbackFor = Exception.class)
public void updateMenu() throws Exception {
    // Initialize the database
    menuService.saveOrUpdate(menu);
    int databaseSizeBeforeUpdate = menuService.list().size();
    // Update the menu
    MenuDo updatedMenuDo = menuService.getById(menu.getId());
    MenuDto managedMenuVM = new MenuDto();
    managedMenuVM.setName(UPDATED_NAME);
    managedMenuVM.setPermission(UPDATED_PERMISSION);
    managedMenuVM.setIcon(UPDATED_ICON);
    managedMenuVM.setSort(UPDATED_SORT);
    managedMenuVM.setHidden(UPDATED_HIDDEN);
    managedMenuVM.setCache(UPDATED_CACHE);
    managedMenuVM.setIframe(UPDATED_IFRAME);
    managedMenuVM.setParentId(UPDATED_PARENT_ID);
    managedMenuVM.setComponent(UPDATED_COMPONENT);
    managedMenuVM.setPath(UPDATED_PATH);
    managedMenuVM.setType(UPDATED_TYPE);
    managedMenuVM.setDescription(UPDATED_DESCRIPTION);
    managedMenuVM.setId(updatedMenuDo.getId());
    restMenuMockMvc.perform(post(DEFAULT_API_URL).contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(managedMenuVM))).andExpect(status().isOk()).andExpect(jsonPath("$.code").value(CommonConstants.SUCCESS));
    // Validate the Menu in the database
    List<MenuDo> menuDoList = menuService.list();
    assertThat(menuDoList).hasSize(databaseSizeBeforeUpdate);
    MenuDo testMenuDo = menuService.getById(updatedMenuDo.getId());
    assertThat(testMenuDo.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testMenuDo.getPermission()).isEqualTo(UPDATED_PERMISSION);
    assertThat(testMenuDo.getIcon()).isEqualTo(UPDATED_ICON);
    assertThat(testMenuDo.getHidden()).isEqualTo(UPDATED_HIDDEN);
    assertThat(testMenuDo.getCache()).isEqualTo(UPDATED_CACHE);
    assertThat(testMenuDo.getIframe()).isEqualTo(UPDATED_IFRAME);
    assertThat(testMenuDo.getSort()).isEqualTo(UPDATED_SORT);
    assertThat(testMenuDo.getParentId()).isEqualTo(UPDATED_PARENT_ID);
    // assertThat(testMenu.getParentIds()).contains(UPDATED_PARENT_ID);
    assertThat(testMenuDo.getComponent()).isEqualTo(UPDATED_COMPONENT);
    assertThat(testMenuDo.getPath()).isEqualTo(UPDATED_PATH);
    assertThat(testMenuDo.getType()).isEqualTo(UPDATED_TYPE);
    assertThat(testMenuDo.isLeaf()).isEqualTo(true);
    assertThat(testMenuDo.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
    assertThat(testMenuDo.getDelFlag()).isEqualTo(MenuDo.FLAG_NORMAL);
}
Also used : MenuDo(com.albedo.java.modules.sys.domain.MenuDo) MenuDto(com.albedo.java.modules.sys.domain.dto.MenuDto) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with MenuDto

use of com.albedo.java.modules.sys.domain.dto.MenuDto in project albedo by somowhere.

the class MenuDoResourceIntTest method createMenuWithExistingCode.

@Test
@Transactional(rollbackFor = Exception.class)
public void createMenuWithExistingCode() throws Exception {
    // Initialize the database
    menuService.saveOrUpdate(menu);
    int databaseSizeBeforeCreate = menuService.list().size();
    // Create the Menu
    MenuDto managedMenuVM = createEntity();
    // Create the Menu
    restMenuMockMvc.perform(post(DEFAULT_API_URL).contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(managedMenuVM))).andExpect(status().isOk()).andExpect(jsonPath("$.code").value(ResponseCode.FAIL.getCode())).andExpect(jsonPath("$.message").isNotEmpty());
    // Validate the Menu in the database
    List<MenuDo> menuDoList = menuService.list();
    assertThat(menuDoList).hasSize(databaseSizeBeforeCreate);
}
Also used : MenuDo(com.albedo.java.modules.sys.domain.MenuDo) MenuDto(com.albedo.java.modules.sys.domain.dto.MenuDto) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with MenuDto

use of com.albedo.java.modules.sys.domain.dto.MenuDto in project albedo by somowhere.

the class MenuDoResourceIntTest method updateMenuExistingPermission.

@Test
@Transactional(rollbackFor = Exception.class)
public void updateMenuExistingPermission() throws Exception {
    menuService.saveOrUpdate(menu);
    // Update the menu
    MenuDo updatedMenuDo = menuService.getById(menu.getId());
    MenuDto managedMenuVM = new MenuDto();
    managedMenuVM.setName(DEFAULT_ANOTHER_NAME);
    managedMenuVM.setIcon(DEFAULT_ANOTHER_ICON);
    managedMenuVM.setParentId(DEFAULT_ANOTHER_PARENT_ID);
    managedMenuVM.setPermission(DEFAULT_ANOTHER_PERMISSION);
    managedMenuVM.setHidden(DEFAULT_HIDDEN);
    managedMenuVM.setCache(DEFAULT_CACHE);
    managedMenuVM.setIframe(DEFAULT_IFRAME);
    managedMenuVM.setSort(DEFAULT_SORT);
    managedMenuVM.setComponent(DEFAULT_COMPONENT);
    managedMenuVM.setType(DEFAULT_TYPE);
    managedMenuVM.setPath(DEFAULT_PATH);
    managedMenuVM.setDescription(DEFAULT_DESCRIPTION);
    managedMenuVM.setId(updatedMenuDo.getId());
    restMenuMockMvc.perform(post(DEFAULT_API_URL).contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(managedMenuVM))).andExpect(status().isOk()).andExpect(jsonPath("$.code").value(ResponseCode.FAIL.getCode())).andExpect(jsonPath("$.message").isNotEmpty());
    // Update the menu
    MenuDo updatedMenuAfterDo = menuService.getById(menu.getId());
    assertThat(updatedMenuAfterDo.getPermission()).isEqualTo(updatedMenuDo.getPermission());
}
Also used : MenuDo(com.albedo.java.modules.sys.domain.MenuDo) MenuDto(com.albedo.java.modules.sys.domain.dto.MenuDto) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

MenuDto (com.albedo.java.modules.sys.domain.dto.MenuDto)4 MenuDo (com.albedo.java.modules.sys.domain.MenuDo)3 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)3