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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations