Search in sources :

Example 1 with DictDo

use of com.albedo.java.modules.sys.domain.DictDo 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 2 with DictDo

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

the class DictDoResourceIntTest method createDict.

@Test
@Transactional(rollbackFor = Exception.class)
public void createDict() throws Exception {
    List<DictDo> databaseSizeBeforeCreate = dictService.list();
    // Create the Dict
    restDictMockMvc.perform(post(DEFAULT_API_URL).contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(dict))).andExpect(status().isOk());
    // Validate the Dict in the database
    List<DictDo> dictDoList = dictService.list();
    assertThat(dictDoList).hasSize(databaseSizeBeforeCreate.size() + 1);
    DictDo testDictDo = dictService.getOne(Wrappers.<DictDo>query().lambda().eq(DictDo::getName, dict.getName()));
    assertThat(testDictDo.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testDictDo.getCode()).isEqualTo(DEFAULT_CODE);
    assertThat(testDictDo.getVal()).isEqualTo(DEFAULT_VAL);
    assertThat(testDictDo.getSort()).isEqualTo(DEFAULT_SORT);
    assertThat(testDictDo.getParentId()).isEqualTo(anotherDict.getId());
    assertThat(testDictDo.getParentIds()).contains(String.valueOf(anotherDict.getId()));
    assertThat(testDictDo.isLeaf()).isEqualTo(true);
    assertThat(testDictDo.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
    assertThat(testDictDo.getDelFlag()).isEqualTo(DictDo.FLAG_NORMAL);
}
Also used : 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 DictDo

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

the class DictDoResourceIntTest method testDictEquals.

@Test
@Transactional(rollbackFor = Exception.class)
public void testDictEquals() throws Exception {
    TestUtil.equalsVerifier(DictDo.class);
    DictDo dictDo1 = new DictDo();
    dictDo1.setId(1L);
    dictDo1.setName("Dict1");
    DictDo dictDo2 = new DictDo();
    dictDo2.setId(dictDo1.getId());
    dictDo2.setName(dictDo1.getName());
    assertThat(dictDo1).isEqualTo(dictDo2);
    dictDo2.setId(2L);
    dictDo2.setName("Dict2");
    assertThat(dictDo1).isNotEqualTo(dictDo2);
    dictDo1.setId(null);
    assertThat(dictDo1).isNotEqualTo(dictDo2);
}
Also used : 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 DictDo

use of com.albedo.java.modules.sys.domain.DictDo 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 5 with DictDo

use of com.albedo.java.modules.sys.domain.DictDo 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

DictDo (com.albedo.java.modules.sys.domain.DictDo)7 Test (org.junit.jupiter.api.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Transactional (org.springframework.transaction.annotation.Transactional)5 DictDto (com.albedo.java.modules.sys.domain.dto.DictDto)3 BizException (com.albedo.java.common.core.exception.BizException)1 DictCacheKeyBuilder (com.albedo.java.modules.sys.cache.DictCacheKeyBuilder)1 CellRangeAddressList (org.apache.poi.ss.util.CellRangeAddressList)1