Search in sources :

Example 1 with DictDto

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

the class DictDoResourceIntTest method createEntity.

/**
 * Create a Dict.
 * <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 Dict domain.
 */
public DictDto createEntity() {
    DictDto dict = new DictDto();
    dict.setName(DEFAULT_NAME);
    dict.setVal(DEFAULT_VAL);
    dict.setCode(DEFAULT_CODE);
    dict.setSort(DEFAULT_SORT);
    dict.setRemark(DEFAULT_REMARK);
    dict.setDescription(DEFAULT_DESCRIPTION);
    return dict;
}
Also used : DictDto(com.albedo.java.modules.sys.domain.dto.DictDto)

Example 2 with DictDto

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

the class DictDoResourceIntTest method updateDictExistingCode.

@Test
@Transactional(rollbackFor = Exception.class)
public void updateDictExistingCode() throws Exception {
    dictService.saveOrUpdate(dict);
    // Update the dict
    DictDo updatedDictDo = dictService.getById(dict.getId());
    DictDto managedDictVM = new DictDto();
    managedDictVM.setName(DEFAULT_ANOTHER_NAME);
    managedDictVM.setVal(DEFAULT_ANOTHER_VAL);
    managedDictVM.setParentId(DEFAULT_ANOTHER_PARENT_ID);
    managedDictVM.setCode(DEFAULT_ANOTHER_CODE);
    managedDictVM.setSort(DEFAULT_SORT);
    managedDictVM.setRemark(DEFAULT_REMARK);
    managedDictVM.setDescription(DEFAULT_DESCRIPTION);
    managedDictVM.setId(updatedDictDo.getId());
    restDictMockMvc.perform(post(DEFAULT_API_URL).contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(managedDictVM))).andExpect(status().isOk()).andExpect(jsonPath("$.code").value(ResponseCode.FAIL.getCode())).andExpect(jsonPath("$.message").isNotEmpty());
    // Update the dict
    DictDo updatedDictAfterDo = dictService.getById(dict.getId());
    assertThat(updatedDictAfterDo.getCode()).isEqualTo(updatedDictDo.getCode());
}
Also used : DictDto(com.albedo.java.modules.sys.domain.dto.DictDto) DictDo(com.albedo.java.modules.sys.domain.DictDo) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with DictDto

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

the class DictDoResourceIntTest method createDictWithExistingCode.

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

Example 4 with DictDto

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

the class DictDoResourceIntTest method updateDict.

@Test
@Transactional(rollbackFor = Exception.class)
public void updateDict() throws Exception {
    // Initialize the database
    dictService.saveOrUpdate(dict);
    int databaseSizeBeforeUpdate = dictService.list().size();
    // Update the dict
    DictDo updatedDictDo = dictService.getById(dict.getId());
    DictDto managedDictVM = new DictDto();
    managedDictVM.setName(UPDATED_NAME);
    managedDictVM.setCode(UPDATED_CODE);
    managedDictVM.setVal(UPDATED_VAL);
    managedDictVM.setSort(UPDATED_SORT);
    managedDictVM.setParentId(UPDATED_PARENT_ID);
    managedDictVM.setRemark(UPDATED_REMARK);
    managedDictVM.setDescription(UPDATED_DESCRIPTION);
    managedDictVM.setId(updatedDictDo.getId());
    restDictMockMvc.perform(post(DEFAULT_API_URL).contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(managedDictVM))).andExpect(status().isOk()).andExpect(jsonPath("$.code").value(CommonConstants.SUCCESS));
    // Validate the Dict in the database
    List<DictDo> dictDoList = dictService.list();
    assertThat(dictDoList).hasSize(databaseSizeBeforeUpdate);
    DictDo testDictDo = dictService.getById(updatedDictDo.getId());
    assertThat(testDictDo.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testDictDo.getCode()).isEqualTo(UPDATED_CODE);
    assertThat(testDictDo.getVal()).isEqualTo(UPDATED_VAL);
    assertThat(testDictDo.getSort()).isEqualTo(UPDATED_SORT);
    assertThat(testDictDo.getParentId()).isEqualTo(UPDATED_PARENT_ID);
    // assertThat(testDict.getParentIds()).contains(UPDATED_PARENT_ID);
    assertThat(testDictDo.isLeaf()).isEqualTo(true);
    assertThat(testDictDo.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
    assertThat(testDictDo.getDelFlag()).isEqualTo(DictDo.FLAG_NORMAL);
}
Also used : DictDto(com.albedo.java.modules.sys.domain.dto.DictDto) DictDo(com.albedo.java.modules.sys.domain.DictDo) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

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