Search in sources :

Example 76 with DataDefinition

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());
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 77 with DataDefinition

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"));
}
Also used : SearchResult(com.qcadoo.model.api.search.SearchResult) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 78 with DataDefinition

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());
}
Also used : SearchResult(com.qcadoo.model.api.search.SearchResult) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 79 with DataDefinition

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());
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 80 with DataDefinition

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());
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Aggregations

DataDefinition (com.qcadoo.model.api.DataDefinition)415 Entity (com.qcadoo.model.api.Entity)285 Test (org.junit.Test)165 BigDecimal (java.math.BigDecimal)53 FieldDefinition (com.qcadoo.model.api.FieldDefinition)48 List (java.util.List)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)32 Service (org.springframework.stereotype.Service)31 Autowired (org.springframework.beans.factory.annotation.Autowired)27 Date (java.util.Date)26 Map (java.util.Map)26 Collectors (java.util.stream.Collectors)26 FormComponent (com.qcadoo.view.api.components.FormComponent)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)23 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)22 IOException (java.io.IOException)21 Objects (java.util.Objects)21 GridComponent (com.qcadoo.view.api.components.GridComponent)20 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)20 Lists (com.google.common.collect.Lists)16