use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
the class AdvanceOrderDAOTest method shouldSaveUpdatedAdvanceOrder.
@Test
public void shouldSaveUpdatedAdvanceOrder() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
advanceOrder = sut.save(advanceOrder);
advanceOrder.setStatus(Status.DONE);
dbInstance.commitAndCloseSession();
AdvanceOrder savedAdvanceOrder = sut.save(advanceOrder);
dbInstance.commitAndCloseSession();
assertThat(savedAdvanceOrder.getStatus()).isEqualTo(Status.DONE);
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
the class AdvanceOrderDAOTest method shouldNotExistIfTheIdentifierValueIsDifferent.
@Test
public void shouldNotExistIfTheIdentifierValueIsDifferent() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
sut.save(advanceOrder);
dbInstance.commitAndCloseSession();
boolean exists = sut.exists(identity, IDENTIFIER_KEY, "otherValue", freeMethod);
assertThat(exists).isFalse();
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
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 klemens.
the class AdvanceOrderDAOTest method shouldExistIfAllValuesTheSame.
@Test
public void shouldExistIfAllValuesTheSame() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
sut.save(advanceOrder);
dbInstance.commitAndCloseSession();
boolean exists = sut.exists(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
assertThat(exists).isTrue();
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
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);
}
}
Aggregations