use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
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 klemens.
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 klemens.
the class AdvanceOrderDAOTest method shouldDeleteAdvaceOrderByKey.
@Test
public void shouldDeleteAdvaceOrderByKey() {
AdvanceOrder aoToKeep1 = sut.create(identity, IdentifierKey.internalId, IDENTIFIER_VALUE, freeMethod);
sut.save(aoToKeep1);
AdvanceOrder aoToDelete = sut.create(identity, IdentifierKey.externalId, IDENTIFIER_VALUE, freeMethod);
aoToDelete = sut.save(aoToDelete);
AdvanceOrder aoToKeep2 = sut.create(identity, IdentifierKey.externalRef, IDENTIFIER_VALUE, freeMethod);
sut.save(aoToKeep2);
AdvanceOrder aoToKeep3 = sut.create(identity, IdentifierKey.internalId, "not matching", freeMethod);
sut.save(aoToKeep3);
dbInstance.commitAndCloseSession();
sut.deleteAdvanceOrder(aoToDelete);
assertThat(sut.loadPendingAdvanceOrders(identity)).hasSize(3).doesNotContain(aoToDelete);
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
the class AdvanceOrderDAOTest method shouldSaveNewAdvanceOrder.
@Test
public void shouldSaveNewAdvanceOrder() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
dbInstance.commitAndCloseSession();
AdvanceOrder savedAdvanceOrder = sut.save(advanceOrder);
dbInstance.commitAndCloseSession();
assertThat(savedAdvanceOrder.getKey()).isNotNull();
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
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);
}
Aggregations