Search in sources :

Example 46 with IdmTreeTypeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.

the class TreeNodeAndTypeRestTest method testCreateRootNodeTwice.

@Test
public void testCreateRootNodeTwice() {
    IdmTreeTypeDto type = getHelper().createTreeType();
    IdmTreeNodeDto root = new IdmTreeNodeDto();
    root.setCode(getHelper().createName());
    root.setName(getHelper().createName());
    root.setTreeType(type.getId());
    // save first root
    Exception ex = null;
    try {
        treeNodeService.save(root);
    } catch (Exception e) {
        ex = e;
    }
    assertNull(ex);
    // save second root, same type
    Map<String, String> body = new HashMap<>();
    body.put("code", getHelper().createName());
    body.put("name", getHelper().createName());
    body.put("treeType", type.getId().toString());
    String jsonContent = toJson(body);
    ex = null;
    int status = 0;
    try {
        status = getMockMvc().perform(post(BaseDtoController.BASE_PATH + "/tree-nodes").with(authentication(getAdminAuthentication())).content(jsonContent).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getStatus();
    } catch (Exception e) {
        ex = e;
    }
    assertNull(ex);
    assertEquals(201, status);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) HashMap(java.util.HashMap) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IdmTreeNodeControllerRestTest(eu.bcvsolutions.idm.core.rest.impl.IdmTreeNodeControllerRestTest) Test(org.junit.Test) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest)

Example 47 with IdmTreeTypeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.

the class TreeNodeCodeGeneratorTest method testAllCombinationWithClassicSave.

@Test
public void testAllCombinationWithClassicSave() {
    IdmTreeTypeDto type = getHelper().createTreeType();
    IdmTreeNodeDto node = new IdmTreeNodeDto();
    node.setTreeType(type.getId());
    node.setName("AB  CDa    bc dř Ř ř");
    IdmGenerateValueDto generator = this.createGenerator(getDtoType(), getGeneratorType(), null, 1, null);
    IdmTreeNodeDto generated = treeNodeService.save(node);
    assertNotNull(generated.getCode());
    assertEquals("abcdabcdrrr", generated.getCode());
    generatedAttributeService.delete(generator);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmGenerateValueDto(eu.bcvsolutions.idm.core.api.dto.IdmGenerateValueDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 48 with IdmTreeTypeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.

the class TreeNodeCodeGeneratorTest method testWhiteSpace.

@Test
public void testWhiteSpace() {
    IdmTreeTypeDto type = getHelper().createTreeType();
    IdmTreeNodeDto node = new IdmTreeNodeDto();
    node.setTreeType(type.getId());
    node.setName("  no  de-  test123");
    IdmGenerateValueDto generator = this.createGenerator(getDtoType(), getGeneratorType(), null, 1, null);
    IdmTreeNodeDto generated = valueGeneratorManager.generate(node);
    assertNotNull(generated.getCode());
    assertEquals("node-test123", generated.getCode());
    generatedAttributeService.delete(generator);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmGenerateValueDto(eu.bcvsolutions.idm.core.api.dto.IdmGenerateValueDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 49 with IdmTreeTypeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.

the class TreeNodeCodeGeneratorTest method testNullName.

@Test
public void testNullName() {
    IdmTreeTypeDto type = getHelper().createTreeType();
    IdmTreeNodeDto node = new IdmTreeNodeDto();
    node.setTreeType(type.getId());
    node.setName(null);
    IdmGenerateValueDto generator = this.createGenerator(getDtoType(), getGeneratorType(), null, 1, null);
    IdmTreeNodeDto generated = valueGeneratorManager.generate(node);
    assertNull(generated.getCode());
    generatedAttributeService.delete(generator);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmGenerateValueDto(eu.bcvsolutions.idm.core.api.dto.IdmGenerateValueDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 50 with IdmTreeTypeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.

the class TreeNodeCodeGeneratorTest method testEmptyName.

@Test
public void testEmptyName() {
    IdmTreeTypeDto type = getHelper().createTreeType();
    IdmTreeNodeDto node = new IdmTreeNodeDto();
    node.setTreeType(type.getId());
    node.setName("");
    IdmGenerateValueDto generator = this.createGenerator(getDtoType(), getGeneratorType(), null, 1, null);
    IdmTreeNodeDto generated = valueGeneratorManager.generate(node);
    assertNotNull(generated.getCode());
    assertTrue(generated.getCode().isEmpty());
    generatedAttributeService.delete(generator);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmGenerateValueDto(eu.bcvsolutions.idm.core.api.dto.IdmGenerateValueDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Aggregations

IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)123 Test (org.junit.Test)91 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)89 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)64 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)44 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)33 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)32 UUID (java.util.UUID)26 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)21 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)21 Transactional (org.springframework.transaction.annotation.Transactional)19 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)18 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)18 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)18 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)16 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)13 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)13 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)11 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)11 LocalDate (java.time.LocalDate)10