use of org.estatio.module.party.dom.role.PartyRole in project estatio by estatio.
the class Party_Test method validate_delete_works.
@Test
public void validate_delete_works() throws Exception {
// given
PartyRoleType typeForTenant = new PartyRoleType();
PartyRole roleForTenant = new PartyRole();
roleForTenant.setRoleType(typeForTenant);
Party partyToDelete = new PartyForTesting();
// party to delete now has tenant role
partyToDelete.getRoles().add(roleForTenant);
partyToDelete.partyRoleTypeRepository = mockPartyRoleTypeRepository;
PartyRoleType typeForSupplier = new PartyRoleType();
PartyRole roleForSupplier = new PartyRole();
roleForSupplier.setRoleType(typeForSupplier);
Party replacementParty = new PartyForTesting();
// replacement party now has supplier role but NOT tenant role
replacementParty.getRoles().add(roleForSupplier);
replacementParty.partyRoleTypeRepository = mockPartyRoleTypeRepository;
// expect
context.checking(new Expectations() {
{
oneOf(mockPartyRoleTypeRepository).findByKey("TENANT");
will(returnValue(typeForTenant));
oneOf(mockPartyRoleTypeRepository).findByKey("SUPPLIER");
will(returnValue(typeForSupplier));
oneOf(mockPartyRoleTypeRepository).findByKey("TENANT");
will(returnValue(null));
}
});
// when, then
Assertions.assertThat(partyToDelete.validateDelete(replacementParty)).isEqualTo("A tenant should not be replaced by a supplier");
}
use of org.estatio.module.party.dom.role.PartyRole in project estatio by estatio.
the class PersonPartyRolesBuilder method execute.
@Override
public void execute(ExecutionContext executionContext) {
checkParam("person", executionContext, Person.class);
for (IPartyRoleType partyRoleType : partyRoleTypes) {
final PartyRole partyRole = partyRoleTypeService.createRole(person, partyRoleType);
object.add(partyRole);
}
}
use of org.estatio.module.party.dom.role.PartyRole in project estatio by estatio.
the class IncomingInvoiceApprovalState_IntegTest method complete_should_fail_when_not_having_appropriate_role_type_test.
@Test
public void complete_should_fail_when_not_having_appropriate_role_type_test() {
Exception error = new Exception();
// given
Person personEmmaWithNoRoleAsPropertyManager = (Person) partyRepository.findPartyByReference(Person_enum.EmmaTreasurerGb.getRef());
SortedSet<PartyRole> rolesforEmma = personEmmaWithNoRoleAsPropertyManager.getRoles();
assertThat(rolesforEmma.size()).isEqualTo(1);
assertThat(rolesforEmma.first().getRoleType()).isEqualTo(partyRoleTypeRepository.findByKey(PartyRoleTypeEnum.TREASURER.getKey()));
// when
try {
// workaround: clear MeService#me cache
queryResultsCache.resetForNextTransaction();
sudoService.sudo(Person_enum.EmmaTreasurerGb.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(IncomingInvoice_complete.class, incomingInvoice)).act("PROPERTY_MANAGER", null, null));
} catch (DisabledException e) {
error = e;
}
assertThat(error.getMessage()).isNotNull();
assertThat(error.getMessage()).contains("Reason: Task assigned to 'PROPERTY_MANAGER' role");
}
use of org.estatio.module.party.dom.role.PartyRole in project estatio by estatio.
the class IncomingInvoiceApprovalState_IntegTest method complete_works_when_having_appropriate_role_type_test.
@Test
public void complete_works_when_having_appropriate_role_type_test() {
Exception error = new Exception();
// given
Person personEmma = (Person) partyRepository.findPartyByReference(Person_enum.EmmaTreasurerGb.getRef());
PartyRoleType roleAsPropertyManager = partyRoleTypeRepository.findByKey("PROPERTY_MANAGER");
personEmma.addRole(roleAsPropertyManager);
transactionService.nextTransaction();
SortedSet<PartyRole> rolesforEmma = personEmma.getRoles();
assertThat(rolesforEmma.size()).isEqualTo(2);
assertThat(rolesforEmma.first().getRoleType()).isEqualTo(partyRoleTypeRepository.findByKey("PROPERTY_MANAGER"));
// when
try {
// workaround: clear MeService#me cache
queryResultsCache.resetForNextTransaction();
sudoService.sudo(Person_enum.EmmaTreasurerGb.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(IncomingInvoice_complete.class, incomingInvoice)).act("PROPERTY_MANAGER", null, null));
} catch (DisabledException e) {
error = e;
}
assertThat(error.getMessage()).isNull();
assertThat(incomingInvoice.getApprovalState()).isEqualTo(IncomingInvoiceApprovalState.COMPLETED);
}
use of org.estatio.module.party.dom.role.PartyRole in project estatio by estatio.
the class EnforceTaskAssignmentPolicySubscriber_applyPolicy_Test method setUp.
@Before
public void setUp() throws Exception {
subscriber = new EnforceTaskAssignmentPolicySubscriber();
subscriber.stateTransitionService = mockStateTransitionService;
subscriber.personRepository = mockPersonRepository;
subscriber.metaModelService3 = mockMetaModelService3;
domainObject = new BankAccount();
stateTransitionClass = BankAccountVerificationStateTransition.class;
pendingTransition = new BankAccountVerificationStateTransition();
personTaskAssignedTo = new Person();
personTaskAssignedTo.setReference("JBLOGGS");
roleTaskAssignedTo = new PartyRoleType();
roleTaskAssignedTo.setKey("Treasurer");
pendingTask = new Task(roleTaskAssignedTo, personTaskAssignedTo, "some description", LocalDateTime.now(), // objectType of transition class
"bankAccount.BankAccountVerificationStateTransition");
pendingTransition.setTask(pendingTask);
personForMe = new Person();
personForMe.getRoles().add(new PartyRole(personForMe, roleTaskAssignedTo));
assertThat(pendingTransition.getTask()).isNotNull();
assertThat(personForMe.getRoles()).isNotEmpty();
assertThat(Lists.newArrayList(personForMe.getRoles()).stream().map(PartyRole::getRoleType)).contains(roleTaskAssignedTo);
}
Aggregations