Search in sources :

Example 6 with RoleCodeEnvironmentProcessor

use of eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleServiceUnitTest method testUpdateSuccessCodeChangeWithEnvironment.

@Test
public void testUpdateSuccessCodeChangeWithEnvironment() {
    when(roleConfiguration.getCodeEnvironmentSeperator()).thenReturn(RoleConfiguration.DEFAULT_CODE_ENVIRONMENT_SEPARATOR);
    // 
    IdmRoleDto role = new IdmRoleDto();
    role.setCode("code");
    role.setBaseCode("code");
    role.setEnvironment("env");
    // 
    IdmRoleDto roleUpdate = new IdmRoleDto();
    roleUpdate.setCode("code2");
    roleUpdate.setBaseCode("code");
    roleUpdate.setEnvironment("env");
    // 
    RoleCodeEnvironmentProcessor roleCodeEnvironmentProcessor = new RoleCodeEnvironmentProcessor(service);
    CoreEvent<IdmRoleDto> updateEvent = new CoreEvent<IdmRoleDto>(CoreEventType.CREATE, roleUpdate);
    updateEvent.setOriginalSource(role);
    IdmRoleDto content = roleCodeEnvironmentProcessor.process(updateEvent).getEvent().getContent();
    // 
    // 
    Assert.assertEquals("code2" + RoleConfiguration.DEFAULT_CODE_ENVIRONMENT_SEPARATOR + "env", content.getCode());
    Assert.assertEquals("code2", content.getBaseCode());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) RoleCodeEnvironmentProcessor(eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 7 with RoleCodeEnvironmentProcessor

use of eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleServiceUnitTest method testUpdateFailureCodeChangeWithEnvironment.

@Test(expected = ResultCodeException.class)
public void testUpdateFailureCodeChangeWithEnvironment() {
    IdmRoleDto role = new IdmRoleDto();
    role.setCode("code");
    role.setBaseCode("code");
    role.setEnvironment("env");
    // 
    IdmRoleDto roleUpdate = new IdmRoleDto();
    roleUpdate.setCode("code2");
    roleUpdate.setBaseCode("code");
    role.setEnvironment("env2");
    // 
    RoleCodeEnvironmentProcessor roleCodeEnvironmentProcessor = new RoleCodeEnvironmentProcessor(service);
    CoreEvent<IdmRoleDto> updateEvent = new CoreEvent<IdmRoleDto>(CoreEventType.CREATE, roleUpdate);
    updateEvent.setOriginalSource(role);
    roleCodeEnvironmentProcessor.process(updateEvent);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) RoleCodeEnvironmentProcessor(eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 8 with RoleCodeEnvironmentProcessor

use of eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleServiceUnitTest method testCreateFaildedWithoutNameAndCode.

@Test(expected = ResultCodeException.class)
public void testCreateFaildedWithoutNameAndCode() {
    IdmRoleDto role = new IdmRoleDto();
    // 
    RoleCodeEnvironmentProcessor roleCodeEnvironmentProcessor = new RoleCodeEnvironmentProcessor(service);
    roleCodeEnvironmentProcessor.process(new CoreEvent<IdmRoleDto>(CoreEventType.CREATE, role)).getEvent().getContent();
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) RoleCodeEnvironmentProcessor(eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 9 with RoleCodeEnvironmentProcessor

use of eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleServiceUnitTest method testCreateSuccessWithBaseCodeOnly.

@Test
public void testCreateSuccessWithBaseCodeOnly() {
    IdmRoleDto role = new IdmRoleDto();
    role.setBaseCode("code");
    // 
    RoleCodeEnvironmentProcessor roleCodeEnvironmentProcessor = new RoleCodeEnvironmentProcessor(service);
    IdmRoleDto content = roleCodeEnvironmentProcessor.process(new CoreEvent<IdmRoleDto>(CoreEventType.CREATE, role)).getEvent().getContent();
    // 
    Assert.assertEquals("code", content.getCode());
    Assert.assertEquals("code", content.getBaseCode());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) RoleCodeEnvironmentProcessor(eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 10 with RoleCodeEnvironmentProcessor

use of eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleServiceUnitTest method testChangeRoleEnvironment.

@Test
public void testChangeRoleEnvironment() {
    when(roleConfiguration.getCodeEnvironmentSeperator()).thenReturn(RoleConfiguration.DEFAULT_CODE_ENVIRONMENT_SEPARATOR);
    // 
    String code = "code";
    String env = "env";
    IdmRoleDto role = new IdmRoleDto();
    role.setBaseCode(code);
    role.setEnvironment(env);
    // 
    RoleCodeEnvironmentProcessor roleCodeEnvironmentProcessor = new RoleCodeEnvironmentProcessor(service);
    IdmRoleDto result = roleCodeEnvironmentProcessor.process(new CoreEvent<IdmRoleDto>(CoreEventType.CREATE, role)).getEvent().getContent();
    // 
    Assert.assertEquals(service.getCodeWithEnvironment(role), result.getCode());
    // 
    role.setBaseCode(code);
    role.setEnvironment(env);
    role.setCode(service.getCodeWithEnvironment(role));
    // 
    result = roleCodeEnvironmentProcessor.process(new CoreEvent<IdmRoleDto>(CoreEventType.CREATE, role)).getEvent().getContent();
    // 
    Assert.assertEquals(service.getCodeWithEnvironment(role), result.getCode());
    // 
    // after environment change
    IdmRoleDto roleUpdate = new IdmRoleDto();
    roleUpdate.setBaseCode(code);
    String envUpdate = "envU";
    roleUpdate.setEnvironment(envUpdate);
    // 
    CoreEvent<IdmRoleDto> updateEvent = new CoreEvent<IdmRoleDto>(CoreEventType.CREATE, roleUpdate);
    updateEvent.setOriginalSource(result);
    IdmRoleDto resultUpdate = roleCodeEnvironmentProcessor.process(updateEvent).getEvent().getContent();
    // 
    Assert.assertEquals(service.getCodeWithEnvironment(roleUpdate), resultUpdate.getCode());
    Assert.assertEquals(code + RoleConfiguration.DEFAULT_CODE_ENVIRONMENT_SEPARATOR + envUpdate, resultUpdate.getCode());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) RoleCodeEnvironmentProcessor(eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Aggregations

IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)13 RoleCodeEnvironmentProcessor (eu.bcvsolutions.idm.core.model.event.processor.role.RoleCodeEnvironmentProcessor)13 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)13 Test (org.junit.Test)13 CoreEvent (eu.bcvsolutions.idm.core.api.event.CoreEvent)6