use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
the class AutoAccessManagerImplTest method shouldNotGrantAccessIfAlreadyDone.
@Test
public void shouldNotGrantAccessIfAlreadyDone() {
Collection<AdvanceOrder> advanceOrders = new ArrayList<>();
AdvanceOrderImpl doneAdvanceOrder = new AdvanceOrderImpl();
doneAdvanceOrder.setStatus(Status.DONE);
doneAdvanceOrder.setIdentifierKey(IdentifierKey.externalId);
doneAdvanceOrder.setIdentifierValue("abc");
advanceOrders.add(doneAdvanceOrder);
sut.grantAccess(advanceOrders);
verify(identifierHandlerMock, never()).findRepositoryEntries(any(IdentifierKey.class), anyString());
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
the class AutoAccessManagerImplTest method getPendingAdvanceOrders.
private Collection<AdvanceOrder> getPendingAdvanceOrders() {
Collection<AdvanceOrder> advanceOrders;
AdvanceOrderImpl ao1 = new AdvanceOrderImpl();
ao1.setIdentifierKey(IdentifierKey.internalId);
ao1.setIdentifierValue("abc");
ao1.setStatus(Status.PENDING);
ao1.setMethod(accessMethodDummy);
ao1.setIdentity(IDENTITY);
AdvanceOrderImpl ao2 = new AdvanceOrderImpl();
ao2.setIdentifierKey(IdentifierKey.internalId);
ao2.setIdentifierValue("abc3");
ao2.setStatus(Status.PENDING);
ao2.setMethod(accessMethodDummy);
ao2.setIdentity(IDENTITY);
advanceOrders = Arrays.asList(ao1, ao2);
return advanceOrders;
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
the class AutoAccessManagerImplTest method shouldMakeOfferBeforeGrantingAccessIfNotExists.
@Test
public void shouldMakeOfferBeforeGrantingAccessIfNotExists() {
when(identifierHandlerMock.findRepositoryEntries(any(IdentifierKey.class), anyString())).thenReturn(listWithRespositotyEntryMock);
when(repositoryEntryRelationDaoMock.hasRole(IDENTITY, repositoryEntryMock, GroupRoles.participant.name())).thenReturn(false);
when(acServiceMock.getValidOfferAccess(any(OLATResource.class), any(AccessMethod.class))).thenReturn(new ArrayList<>());
Offer offerMock = mock(Offer.class);
when(acServiceMock.createOffer(any(OLATResource.class), anyString())).thenReturn(offerMock);
List<AccessMethod> methods = Arrays.asList(accessMethodDummy);
when(acServiceMock.getAvailableMethodsByType(METHOD_CLASS)).thenReturn(methods);
Collection<AdvanceOrder> advanceOrders = getPendingAdvanceOrders();
sut.grantAccess(advanceOrders);
verify(acServiceMock, times(2)).createOffer(any(OLATResource.class), anyString());
verify(acServiceMock, times(2)).createOfferAccess(any(Offer.class), isA(AccessMethod.class));
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project openolat by klemens.
the class AdvanceOrderController method loadModel.
private void loadModel() {
Collection<AdvanceOrder> advanceOrders = autoAccessManager.loadPendingAdvanceOrders(identity);
List<AdvanceOrderRow> rows = new ArrayList<>(advanceOrders.size());
for (AdvanceOrder advanceOrder : advanceOrders) {
rows.add(new AdvanceOrderRow(advanceOrder));
}
dataModel.setObjects(rows);
tableEl.reset(true, true, true);
}
Aggregations