use of org.apache.cayenne.testdo.unsupported_distinct_types.Product in project cayenne by apache.
the class SelectActionWithUnsupportedDistinctTypesIT method testCompositionSelectManyToManyQuery.
@Test
public void testCompositionSelectManyToManyQuery() throws SQLException {
createCompositionManyToManyDataSet();
SelectQuery query = new SelectQuery(Product.class);
query.addPrefetch("contained");
query.addPrefetch("base");
List<Product> result = context.performQuery(query);
assertNotNull(result);
for (Product product : result) {
List<Product> productsContained = product.getContained();
assertNotNull(productsContained);
List<Product> productsBase = product.getBase();
assertNotNull(productsBase);
assertEquals(3, productsContained.size() + productsBase.size());
}
}
use of org.apache.cayenne.testdo.unsupported_distinct_types.Product in project cayenne by apache.
the class SelectActionWithUnsupportedDistinctTypesIT method testOrdersSelectManyToManyQuery.
@Test
public void testOrdersSelectManyToManyQuery() throws SQLException {
createOrdersManyToManyDataSet();
List assertSizes = new ArrayList(3);
assertSizes.addAll(Arrays.asList(1, 2, 3));
SelectQuery productQuery = new SelectQuery(Product.class);
productQuery.addPrefetch("orderBy");
List<Product> productResult = context.performQuery(productQuery);
assertNotNull(productResult);
List orderBySizes = new ArrayList(3);
for (Product product : productResult) {
List<Customer> orderBy = product.getOrderBy();
assertNotNull(orderBy);
orderBySizes.add(orderBy.size());
}
assertTrue(assertSizes.containsAll(orderBySizes));
SelectQuery customerQuery = new SelectQuery(Customer.class);
customerQuery.addPrefetch("order");
List<Customer> customerResult = context.performQuery(customerQuery);
assertNotNull(customerResult);
List orderSizes = new ArrayList(3);
for (Customer customer : customerResult) {
List<Product> orders = customer.getOrder();
assertNotNull(orders);
orderSizes.add(orders.size());
}
assertTrue(assertSizes.containsAll(orderSizes));
}