Search in sources :

Example 71 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class CrudListDtoIntegrationTest method shouldHardDeleteEntity.

@Test
public void shouldHardDeleteEntity() throws Exception {
    // given
    DataDefinition productDataDefinition = getProductDataDefinition();
    DataDefinition productListDtoDataDefinition = getProductListDtoDataDefinition();
    Entity product = productDataDefinition.save(createProduct("asd", "asd"));
    Entity productListDto = productListDtoDataDefinition.get(product.getId());
    verifyHooks.clear();
    // when
    productListDtoDataDefinition.delete(productListDto.getId());
    // then
    int total = jdbcTemplate.queryForInt("select count(*) from " + TABLE_NAME_PRODUCT);
    assertEquals(0, total);
    assertEquals(0, verifyHooks.getNumOfInvocations(HookType.SAVE));
    assertEquals(0, verifyHooks.getNumOfInvocations(HookType.CREATE));
    assertEquals(0, verifyHooks.getNumOfInvocations(HookType.COPY));
    assertEquals(0, verifyHooks.getNumOfInvocations(HookType.UPDATE));
    assertEquals(0, verifyHooks.getNumOfInvocations(HookType.DELETE));
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 72 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class FieldModuleIntegrationTest method shouldCallAdditinanalFieldValidators.

@Test
public void shouldCallAdditinanalFieldValidators() throws Exception {
    // given
    DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
    DataDefinition machineDao = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE);
    DataDefinition componentDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_COMPONENT);
    pluginManager.enablePlugin(PLUGIN_MACHINES_NAME);
    Entity machine = machineDao.save(createMachine("asd"));
    Entity product = createProduct("asd", "asd");
    product = productDao.save(product);
    Entity component = createComponent("name", product, machine);
    component.setField("machineDescription", "as");
    // when
    component = componentDao.save(component);
    // then
    Assert.assertFalse(component.isValid());
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 73 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class FieldModuleIntegrationTest method shouldCallAndPassMaxStringLenFieldValidators.

@Test
public void shouldCallAndPassMaxStringLenFieldValidators() throws Exception {
    // given
    String stringWith300Characters = StringUtils.repeat("a", 300);
    DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
    pluginManager.enablePlugin(PLUGIN_PRODUCTS_NAME);
    Entity product = createProduct(stringWith300Characters, "asd");
    // when
    Entity savedProduct = productDao.save(product);
    // then
    Assert.assertTrue(savedProduct.isValid());
    Assert.assertEquals(stringWith300Characters, savedProduct.getStringField("name"));
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 74 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class HqlIntegrationTest method shouldFindByQueryWithParameters.

@Test
public void shouldFindByQueryWithParameters() 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("where name = :name").setString("name", "asd").uniqueResult();
    // then
    assertEquals(expectedProduct.getId(), product.getId());
    assertEquals(expectedProduct.getStringField("name"), product.getStringField("name"));
    assertEquals(expectedProduct.getDataDefinition(), product.getDataDefinition());
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 75 with DataDefinition

use of com.qcadoo.model.api.DataDefinition in project qcadoo by qcadoo.

the class HqlIntegrationTest method shouldFindByQueryWithInlineEntityId.

@Test
public void shouldFindByQueryWithInlineEntityId() 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.id = " + expectedProduct.getId()).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