use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.
the class HqlIntegrationTest method shouldFindByQueryWithBeanSelect.
@Test
public void shouldFindByQueryWithBeanSelect() throws Exception {
// given
DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
Entity expectedProduct = productDao.save(createProduct("asd", "asd"));
// when
Entity product = productDao.find("select p from #products_product p").uniqueResult();
// then
assertEquals(expectedProduct.getId(), product.getId());
assertEquals(expectedProduct.getDataDefinition(), product.getDataDefinition());
}
use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.
the class HqlIntegrationTest method shouldFindByQueryWithOrderBy.
@Test
public void shouldFindByQueryWithOrderBy() throws Exception {
// given
DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
productDao.save(createProduct("asd", "asd"));
productDao.save(createProduct("csd", "csd"));
productDao.save(createProduct("bsd", "bsd"));
// when
SearchResult result = productDao.find("select p.name from #products_product p order by p.name desc)").list();
// then
assertEquals(3, result.getTotalNumberOfEntities());
assertEquals("csd", result.getEntities().get(0).getField("0"));
assertEquals("bsd", result.getEntities().get(1).getField("0"));
assertEquals("asd", result.getEntities().get(2).getField("0"));
}
use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.
the class HqlIntegrationTest method shouldFindAllByQuery.
@Test
public void shouldFindAllByQuery() throws Exception {
// given
DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
productDao.save(createProduct("asd", "asd"));
productDao.save(createProduct("asd2", "asd2"));
// when
SearchResult result = productDao.find("").list();
// then
assertEquals(2, result.getTotalNumberOfEntities());
assertEquals(2, result.getEntities().size());
}
use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.
the class HqlIntegrationTest method shouldFindByQueryWithSubqueriesOnCollection.
@Test
public void shouldFindByQueryWithSubqueriesOnCollection() throws Exception {
// given
DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
DataDefinition partDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PART);
productDao.save(createProduct("qwe", "qwe"));
Entity expectedProduct = productDao.save(createProduct("asd", "asd"));
partDao.save(createPart("name", expectedProduct));
// when
Entity product = productDao.find("from #products_product as p where exists(from p.parts)").uniqueResult();
// then
assertEquals(expectedProduct.getId(), product.getId());
assertEquals(expectedProduct.getDataDefinition(), product.getDataDefinition());
}
use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.
the class HqlIntegrationTest method shouldFindByQueryWithEntityParameters.
@Test
public void shouldFindByQueryWithEntityParameters() throws Exception {
// given
DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
DataDefinition partDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PART);
Entity expectedProduct = productDao.save(createProduct("asd", "asd"));
Entity expectedPart = partDao.save(createPart("name", expectedProduct));
// when
Entity part = partDao.find("where product = :product").setEntity("product", expectedProduct).uniqueResult();
// then
assertEquals(expectedPart.getId(), part.getId());
assertEquals(expectedPart.getDataDefinition(), part.getDataDefinition());
}
Aggregations