use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
the class AdvanceOrderDAOTest method shouldFindPendingAdvaceOrderForIdentifiers.
@Test
public void shouldFindPendingAdvaceOrderForIdentifiers() {
AdvanceOrder aoMatchingInternalId = sut.create(identity, IdentifierKey.internalId, IDENTIFIER_VALUE, freeMethod);
sut.save(aoMatchingInternalId);
AdvanceOrder aoMatchingExternalId = sut.create(identity, IdentifierKey.externalId, IDENTIFIER_VALUE, freeMethod);
sut.save(aoMatchingExternalId);
AdvanceOrder aoNotMatchingRef = sut.create(identity, IdentifierKey.externalRef, IDENTIFIER_VALUE, freeMethod);
sut.save(aoNotMatchingRef);
AdvanceOrder aoNotMatchingValue = sut.create(identity, IdentifierKey.internalId, "not matching", freeMethod);
sut.save(aoNotMatchingValue);
dbInstance.commitAndCloseSession();
Map<IdentifierKey, String> identifiers = new HashMap<>();
identifiers.put(IdentifierKey.internalId, IDENTIFIER_VALUE);
identifiers.put(IdentifierKey.externalId, IDENTIFIER_VALUE);
Collection<AdvanceOrder> advanceOrders = sut.loadPendingAdvanceOrders(identifiers);
assertThat(advanceOrders).hasSize(2).contains(aoMatchingInternalId, aoMatchingExternalId);
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
the class AdvanceOrderDAOTest method shouldFindPendingAdvanceOrderForIdentity.
@Test
public void shouldFindPendingAdvanceOrderForIdentity() {
AdvanceOrder firstPendingAdvanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
sut.save(firstPendingAdvanceOrder);
AdvanceOrder secondPendingAdvanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
sut.save(secondPendingAdvanceOrder);
Identity otherIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("other");
AdvanceOrder advanceOrderWithOtherIdentity = sut.create(otherIdentity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
sut.save(advanceOrderWithOtherIdentity);
AdvanceOrder doneAdvanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
sut.accomplishAndSave(doneAdvanceOrder);
dbInstance.commitAndCloseSession();
Collection<AdvanceOrder> pendingAdvanceOrders = sut.loadPendingAdvanceOrders(identity);
assertThat(pendingAdvanceOrders).hasSize(2);
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
the class AdvanceOrderDAOTest method shouldFindPendingAdvaceOrderForIdentifiersIfNullValues.
@Test
public void shouldFindPendingAdvaceOrderForIdentifiersIfNullValues() {
AdvanceOrder aoMatchingInternalId = sut.create(identity, IdentifierKey.internalId, IDENTIFIER_VALUE, freeMethod);
sut.save(aoMatchingInternalId);
AdvanceOrder aoMatchingExternalId = sut.create(identity, IdentifierKey.externalId, IDENTIFIER_VALUE, freeMethod);
sut.save(aoMatchingExternalId);
AdvanceOrder aoNotMatchingRef = sut.create(identity, IdentifierKey.externalRef, IDENTIFIER_VALUE, freeMethod);
sut.save(aoNotMatchingRef);
AdvanceOrder aoNotMatchingValue = sut.create(identity, IdentifierKey.internalId, "not matching", freeMethod);
sut.save(aoNotMatchingValue);
dbInstance.commitAndCloseSession();
Map<IdentifierKey, String> identifiers = new HashMap<>();
identifiers.put(IdentifierKey.internalId, IDENTIFIER_VALUE);
identifiers.put(null, IDENTIFIER_VALUE);
identifiers.put(IdentifierKey.externalId, "");
Collection<AdvanceOrder> advanceOrders = sut.loadPendingAdvanceOrders(identifiers);
assertThat(advanceOrders).hasSize(1).contains(aoMatchingInternalId);
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
the class AdvanceOrderDAOTest method shouldNotExistIfTheHandlerTypeIsDifferent.
@Test
public void shouldNotExistIfTheHandlerTypeIsDifferent() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
sut.save(advanceOrder);
dbInstance.commitAndCloseSession();
boolean exists = sut.exists(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, tokenMethod);
assertThat(exists).isFalse();
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
the class AdvanceOrderDAOTest method shouldNotMarkedAsDoneIfNoOffer.
@Test
public void shouldNotMarkedAsDoneIfNoOffer() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
advanceOrder = sut.save(advanceOrder);
AdvanceOrder accomplishedAdvanceOrder = sut.accomplishAndSave(advanceOrder);
assertThat(accomplishedAdvanceOrder.getStatus()).isEqualTo(advanceOrder.getStatus());
}
Aggregations