Search in sources :

Example 6 with RawOrderItem

use of org.olat.resource.accesscontrol.model.RawOrderItem in project OpenOLAT by OpenOLAT.

the class ACOrderManagerTest method findOrderItems.

@Test
public void findOrderItems() {
    // create an offer to buy
    OLATResource randomOres = createResource();
    Offer offer = acService.createOffer(randomOres, "TestSaveOrder");
    offer = acService.save(offer);
    dbInstance.commitAndCloseSession();
    // create and save an order
    Order order = acOrderManager.createOrder(ident1);
    OrderPart part = acOrderManager.addOrderPart(order);
    OrderLine line = acOrderManager.addOrderLine(part, offer);
    order = acOrderManager.save(order);
    Assert.assertNotNull(order);
    Assert.assertNotNull(order.getDelivery());
    Assert.assertNotNull(line);
    Assert.assertEquals(ident1, order.getDelivery());
    dbInstance.commitAndCloseSession();
    long start = System.nanoTime();
    List<RawOrderItem> items = acOrderManager.findNativeOrderItems(randomOres, null, null, null, null, null, 0, -1, null);
    CodeHelper.printNanoTime(start, "Order itemized");
    Assert.assertNotNull(items);
}
Also used : RawOrderItem(org.olat.resource.accesscontrol.model.RawOrderItem) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Example 7 with RawOrderItem

use of org.olat.resource.accesscontrol.model.RawOrderItem in project openolat by klemens.

the class ACOrderManagerTest method findOrderItems_1.

@Test
public void findOrderItems_1() {
    // create an offer to buy
    List<AccessMethod> methods = acMethodManager.getAvailableMethodsByType(TokenAccessMethod.class);
    assertNotNull(methods);
    assertEquals(1, methods.size());
    AccessMethod tokenMethod = methods.get(0);
    OLATResource randomOres = createResource();
    Offer offer = acService.createOffer(randomOres, "TestSaveOrder");
    offer = acService.save(offer);
    dbInstance.commitAndCloseSession();
    // create and save an order
    Order order = acOrderManager.createOrder(ident1);
    OrderPart part = acOrderManager.addOrderPart(order);
    OrderLine line = acOrderManager.addOrderLine(part, offer);
    order = acOrderManager.save(order);
    Assert.assertNotNull(order);
    Assert.assertNotNull(order.getDelivery());
    Assert.assertNotNull(line);
    Assert.assertEquals(ident1, order.getDelivery());
    dbInstance.commitAndCloseSession();
    AccessTransaction accessTransaction = acTransactionManager.createTransaction(order, part, tokenMethod);
    assertNotNull(accessTransaction);
    acTransactionManager.save(accessTransaction);
    AccessTransaction accessTransaction2 = acTransactionManager.createTransaction(order, part, tokenMethod);
    assertNotNull(accessTransaction2);
    acTransactionManager.save(accessTransaction2);
    dbInstance.commitAndCloseSession();
    acTransactionManager.update(accessTransaction, AccessTransactionStatus.NEW);
    acTransactionManager.update(accessTransaction2, AccessTransactionStatus.CANCELED);
    long start = System.nanoTime();
    List<RawOrderItem> items = acOrderManager.findNativeOrderItems(randomOres, null, null, null, null, null, 0, -1, null);
    CodeHelper.printNanoTime(start, "Order itemized");
    Assert.assertNotNull(items);
    // check the order by
    for (OrderCol col : OrderCol.values()) {
        List<RawOrderItem> rawItems = acOrderManager.findNativeOrderItems(randomOres, null, null, null, null, null, 0, -1, null, new SortKey(col.sortKey(), false));
        Assert.assertNotNull(rawItems);
    }
}
Also used : OLATResource(org.olat.resource.OLATResource) SortKey(org.olat.core.commons.persistence.SortKey) RawOrderItem(org.olat.resource.accesscontrol.model.RawOrderItem) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) FreeAccessMethod(org.olat.resource.accesscontrol.model.FreeAccessMethod) TokenAccessMethod(org.olat.resource.accesscontrol.model.TokenAccessMethod) OrderCol(org.olat.resource.accesscontrol.ui.OrdersDataModel.OrderCol) Test(org.junit.Test)

Example 8 with RawOrderItem

use of org.olat.resource.accesscontrol.model.RawOrderItem in project openolat by klemens.

the class ACOrderManagerTest method findOrderItems.

@Test
public void findOrderItems() {
    // create an offer to buy
    OLATResource randomOres = createResource();
    Offer offer = acService.createOffer(randomOres, "TestSaveOrder");
    offer = acService.save(offer);
    dbInstance.commitAndCloseSession();
    // create and save an order
    Order order = acOrderManager.createOrder(ident1);
    OrderPart part = acOrderManager.addOrderPart(order);
    OrderLine line = acOrderManager.addOrderLine(part, offer);
    order = acOrderManager.save(order);
    Assert.assertNotNull(order);
    Assert.assertNotNull(order.getDelivery());
    Assert.assertNotNull(line);
    Assert.assertEquals(ident1, order.getDelivery());
    dbInstance.commitAndCloseSession();
    long start = System.nanoTime();
    List<RawOrderItem> items = acOrderManager.findNativeOrderItems(randomOres, null, null, null, null, null, 0, -1, null);
    CodeHelper.printNanoTime(start, "Order itemized");
    Assert.assertNotNull(items);
}
Also used : RawOrderItem(org.olat.resource.accesscontrol.model.RawOrderItem) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Aggregations

RawOrderItem (org.olat.resource.accesscontrol.model.RawOrderItem)8 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 OLATResource (org.olat.resource.OLATResource)4 OrderStatus (org.olat.resource.accesscontrol.OrderStatus)4 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)4 BigDecimal (java.math.BigDecimal)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Query (javax.persistence.Query)2 TypedQuery (javax.persistence.TypedQuery)2 NativeQueryBuilder (org.olat.core.commons.persistence.NativeQueryBuilder)2 SortKey (org.olat.core.commons.persistence.SortKey)2 AccessTransactionStatus (org.olat.resource.accesscontrol.model.AccessTransactionStatus)2 FreeAccessMethod (org.olat.resource.accesscontrol.model.FreeAccessMethod)2 PSPTransactionStatus (org.olat.resource.accesscontrol.model.PSPTransactionStatus)2 TokenAccessMethod (org.olat.resource.accesscontrol.model.TokenAccessMethod)2 OrderTableItem (org.olat.resource.accesscontrol.ui.OrderTableItem)2 Status (org.olat.resource.accesscontrol.ui.OrderTableItem.Status)2