예제 #1
0
  @Test
  public void testFindCustomerWithOrder() {
    int numberOfOrders = 1;

    Customer customer = new Customer();
    customer.setName("Test Customer");

    Order order = new Order();
    order.setOrderNumber("Order_1337");

    customer.getOrders().add(order);

    assertNotNull(polymate.save(customer));

    Iterable<Customer> customers = polymate.find(Customer.class);
    assertNotNull(customers);
    Customer currCustomer = customers.iterator().next();
    List<Order> orders = currCustomer.getOrders();
    assertNotNull(orders);
    Long start = System.currentTimeMillis();
    assertEquals(numberOfOrders, orders.size());
    System.out.println("Took: " + (System.currentTimeMillis() - start));
    Order actualOrder = orders.get(0);
    assertNotNull(actualOrder);
    assertEquals(order.getOrderNumber(), actualOrder.getOrderNumber());
  }
예제 #2
0
  @Test
  public void testAddOrder() {
    Order order = new Order();
    order.setOrderNumber("Order 1");
    assertNotNull(polymate.save(order));

    Iterable<Order> result = polymate.find(Order.class);
    assertNotNull(result);
    assertTrue(result.iterator().hasNext());
    Order order2 = result.iterator().next();
    assertNotNull(order2);
    assertEquals(order.getOrderNumber(), order2.getOrderNumber());
  }
예제 #3
0
  @Test
  public void testAddCustomerWithOrder() {
    int numberOfOrders = 1;

    Customer customer = new Customer();
    customer.setName("Test Customer");

    Order order = new Order();
    order.setOrderNumber("Order_1337");

    customer.getOrders().add(order);

    Customer addedCustomer = polymate.save(customer);
    assertNotNull(addedCustomer);
    assertNotNull(addedCustomer.getOrders());
    assertEquals(numberOfOrders, addedCustomer.getOrders().size());
  }
예제 #4
0
  @Test
  public void testAddCustomerWithMultipleOders() {
    int numberOfOrders = 10;

    Customer customer = new Customer();
    customer.setName("Test Customer");

    for (int i = 1; i <= numberOfOrders; i++) {
      Order order = new Order();
      order.setOrderNumber("Order_" + i);

      customer.getOrders().add(order);
    }

    Customer addedCustomer = polymate.save(customer);
    assertNotNull(addedCustomer);
    assertNotNull(addedCustomer.getOrders());
    assertEquals(numberOfOrders, addedCustomer.getOrders().size());
  }