use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class AdvanceOrderDAOTest method shouldCreateAdvanceOrder.
@Test
public void shouldCreateAdvanceOrder() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
assertThat(advanceOrder.getKey()).isNull();
assertThat(advanceOrder.getCreationDate()).isNotNull();
assertThat(advanceOrder.getLastModified()).isNotNull();
assertThat(advanceOrder.getIdentity()).isEqualTo(identity);
assertThat(advanceOrder.getIdentifierKey()).isEqualTo(IDENTIFIER_KEY);
assertThat(advanceOrder.getIdentifierValue()).isEqualTo(IDENTIFIER_VALUE);
assertThat(advanceOrder.getMethod()).isEqualTo(freeMethod);
assertThat(advanceOrder.getStatus()).isEqualTo(Status.PENDING);
assertThat(advanceOrder.getStatusModified()).isNotNull();
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
the class AdvanceOrderDAOTest method shouldNotExistIfTheIdentifierKeyIsDifferent.
@Test
public void shouldNotExistIfTheIdentifierKeyIsDifferent() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
sut.save(advanceOrder);
dbInstance.commitAndCloseSession();
boolean exists = sut.exists(identity, IdentifierKey.internalId, IDENTIFIER_VALUE, freeMethod);
assertThat(exists).isFalse();
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
the class AutoAccessManagerImpl method createAndPersistAdvanceOrderIfNotExist.
private void createAndPersistAdvanceOrderIfNotExist(Identity identity, IdentifierKey key, String value, Class<? extends AutoAccessMethod> type) {
List<AccessMethod> methods = acService.getAvailableMethodsByType(type);
AccessMethod method = methods.get(0);
if (doesNotExist(identity, key, value, method)) {
AdvanceOrder advanceOrder = advanceOrderDAO.create(identity, key, value, method);
advanceOrderDAO.save(advanceOrder);
}
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
the class AdvanceOrderDAOTest method shouldDeleteAdvanceOrdersByIdentity.
@Test
public void shouldDeleteAdvanceOrdersByIdentity() {
AdvanceOrder aoPending = sut.create(identity, IdentifierKey.internalId, IDENTIFIER_VALUE, freeMethod);
sut.save(aoPending);
AdvanceOrder aoDone = sut.create(identity, IdentifierKey.externalId, IDENTIFIER_VALUE, freeMethod);
sut.save(aoDone);
sut.accomplishAndSave(aoDone);
Identity otherIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("otheruser");
AdvanceOrder aoOtherIdentity = sut.create(otherIdentity, IdentifierKey.internalId, "not matching", freeMethod);
sut.save(aoOtherIdentity);
dbInstance.commitAndCloseSession();
sut.deleteAdvanceOrders(identity);
Collection<AdvanceOrder> aoDeletedUser = loadAllAdvanceOrders(identity);
assertThat(aoDeletedUser).hasSize(0);
Collection<AdvanceOrder> aoActiveUser = loadAllAdvanceOrders(otherIdentity);
assertThat(aoActiveUser).hasSize(1);
}
Aggregations