use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceTest method testFormAttributes.
/**
* Test add and delete extended attributes to owner
*/
@Test
public void testFormAttributes() {
// create owner
SysSystemDto system = new SysSystemDto();
system.setName(SYSTEM_NAME_ONE);
system = systemService.save(system);
SysSystemDto systemOne = systemService.getByCode(SYSTEM_NAME_ONE);
assertEquals(SYSTEM_NAME_ONE, systemOne.getName());
//
// create definition one
IdmFormDefinitionDto formDefinitionOne = new IdmFormDefinitionDto();
formDefinitionOne.setType(SysSystem.class.getCanonicalName());
formDefinitionOne.setCode("v1");
formDefinitionOne = formDefinitionService.save(formDefinitionOne);
IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
attributeDefinitionOne.setFormDefinition(formDefinitionOne.getId());
attributeDefinitionOne.setCode("name_" + System.currentTimeMillis());
attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
attributeDefinitionOne.setPersistentType(PersistentType.TEXT);
attributeDefinitionOne = formAttributeService.save(attributeDefinitionOne);
formDefinitionOne = formDefinitionService.get(formDefinitionOne.getId());
//
// create definition two
IdmFormDefinitionDto formDefinitionTwo = new IdmFormDefinitionDto();
formDefinitionTwo.setType(SysSystem.class.getCanonicalName());
formDefinitionTwo.setCode("v2");
formDefinitionTwo = formDefinitionService.save(formDefinitionTwo);
IdmFormAttributeDto attributeDefinitionTwo = new IdmFormAttributeDto();
attributeDefinitionTwo.setFormDefinition(formDefinitionTwo.getId());
attributeDefinitionTwo.setCode("name_" + System.currentTimeMillis());
attributeDefinitionTwo.setName(attributeDefinitionTwo.getCode());
attributeDefinitionTwo.setPersistentType(PersistentType.TEXT);
attributeDefinitionTwo = formAttributeService.save(attributeDefinitionTwo);
formDefinitionTwo = formDefinitionService.get(formDefinitionTwo.getId());
//
IdmFormValueDto value1 = new IdmFormValueDto(attributeDefinitionOne);
value1.setValue("test1");
IdmFormValueDto value2 = new IdmFormValueDto(attributeDefinitionTwo);
value2.setValue("test2");
formService.saveValues(system, formDefinitionOne, Lists.newArrayList(value1));
formService.saveValues(system, formDefinitionTwo, Lists.newArrayList(value2));
assertEquals("test1", formService.getValues(system, formDefinitionOne).get(0).getStringValue());
assertEquals("test2", formService.getValues(system, formDefinitionTwo).get(0).getStringValue());
assertEquals("test2", formService.getValues(system, formDefinitionTwo, attributeDefinitionTwo.getName()).get(0).getValue());
//
// create second owner
SysSystemDto systemTwo = new SysSystemDto();
systemTwo.setName(SYSTEM_NAME_TWO);
systemTwo = systemService.save(systemTwo);
assertEquals(0, formService.getValues(systemTwo, formDefinitionOne).size());
assertEquals(0, formService.getValues(systemTwo, formDefinitionTwo).size());
assertEquals(1, formService.getValues(system, formDefinitionOne).size());
assertEquals(1, formService.getValues(system, formDefinitionTwo).size());
systemService.delete(systemTwo);
assertEquals(1, formService.getValues(system, formDefinitionOne).size());
assertEquals(1, formService.getValues(system, formDefinitionTwo).size());
formService.deleteValues(system, formDefinitionOne);
assertEquals(0, formService.getValues(system, formDefinitionOne).size());
assertEquals("test2", formService.getValues(system, formDefinitionTwo).get(0).getStringValue());
systemService.delete(system);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceTest method checkSystemUnValid.
@Test(expected = RuntimeException.class)
public void checkSystemUnValid() {
// create test system
SysSystemDto system = helper.createSystem(TestResource.TABLE_NAME);
// set wrong password
formService.saveValues(system, "password", ImmutableList.of("wrongPassword"));
// do test system
systemService.checkSystem(system);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceTest method testReferentialIntegritySystemEntityExists.
@Test
public void testReferentialIntegritySystemEntityExists() {
SysSystemDto system = new SysSystemDto();
String systemName = "t_s_" + System.currentTimeMillis();
system.setName(systemName);
system = systemService.save(system);
// system entity
SysSystemEntityDto systemEntity = new SysSystemEntityDto();
systemEntity.setSystem(system.getId());
systemEntity.setEntityType(SystemEntityType.IDENTITY);
systemEntity.setUid("se_uid_" + System.currentTimeMillis());
systemEntity = systemEntityService.save(systemEntity);
systemService.delete(system);
assertNull(systemService.getByCode(system.getCode()));
assertNull(systemEntityService.get(systemEntity.getId()));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceTest method testFillConnectorConfiguration.
@Test
public void testFillConnectorConfiguration() {
// create owner
@SuppressWarnings("deprecation") SysSystemDto system = systemService.createTestSystem();
IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(system);
assertEquals(15, connectorConfiguration.getConfigurationProperties().getProperties().size());
//
// check all supported data types
// TODO: add all supported types
Integer checked = 0;
for (IcConfigurationProperty property : connectorConfiguration.getConfigurationProperties().getProperties()) {
switch(property.getName()) {
case "host":
{
assertEquals("localhost", property.getValue());
checked++;
break;
}
case "password":
{
assertEquals(new org.identityconnectors.common.security.GuardedString("idmadmin".toCharArray()), property.getValue());
checked++;
break;
}
case "rethrowAllSQLExceptions":
{
assertEquals(true, property.getValue());
checked++;
break;
}
}
}
;
assertEquals(Integer.valueOf(3), checked);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceTest method duplicateSystem.
@Test
public void duplicateSystem() {
// create test system
SysSystemDto system = helper.createTestResourceSystem(true);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
// Number of schema attributes on original system
int numberOfSchemaAttributesOrig = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
SysSystemMappingDto mappingOrig = helper.getDefaultMapping(system);
// Number of mapping attributes on original system
int numberOfMappingAttributesOrig = systemAttributeMappingService.findBySystemMapping(mappingOrig).size();
SysSystemDto duplicatedSystem = systemService.duplicate(system.getId());
// check duplicate
systemService.checkSystem(duplicatedSystem);
Assert.assertNotEquals(system.getId(), duplicatedSystem.getId());
schemaAttributeFilter.setSystemId(duplicatedSystem.getId());
// Number of schema attributes on duplicated system
int numberOfSchemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
Assert.assertEquals(numberOfSchemaAttributesOrig, numberOfSchemaAttributes);
SysSystemMappingDto mapping = helper.getDefaultMapping(duplicatedSystem);
// Number of mapping attributes on duplicated system
int numberOfMappingAttributes = systemAttributeMappingService.findBySystemMapping(mapping).size();
Assert.assertEquals(numberOfMappingAttributesOrig, numberOfMappingAttributes);
}
Aggregations