use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
the class AdvanceOrderDAOTest method shouldMarkAsDoneWhenAccomplished.
@Test
public void shouldMarkAsDoneWhenAccomplished() {
AdvanceOrder advanceOrder = sut.create(identity, IDENTIFIER_KEY, IDENTIFIER_VALUE, freeMethod);
advanceOrder = sut.save(advanceOrder);
AdvanceOrder accomplishedAdvanceOrder = sut.accomplishAndSave(advanceOrder);
assertThat(accomplishedAdvanceOrder.getStatus()).isEqualTo(Status.DONE);
}
use of org.olat.resource.accesscontrol.provider.auto.AdvanceOrder in project OpenOLAT by OpenOLAT.
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();
}
Aggregations