Search in sources :

Example 56 with DataDefinition

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

the class CrudIntegrationTest method shouldNotSetReadOnlyFieldOnCreate.

@Test
public void shouldNotSetReadOnlyFieldOnCreate() throws Exception {
    // given
    DataDefinition machineDataDefinition = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE);
    Entity machine = createMachine("machine");
    // when
    machine.setField("readOnly", "someValue");
    machine = machineDataDefinition.save(machine);
    // then
    assertTrue(machine.isValid());
    assertNull(machine.getField("readOnly"));
    Map<String, Object> result = jdbcTemplate.queryForMap("select * from " + TABLE_NAME_MACHINE);
    assertNotNull(result);
    assertNull(result.get("readOnly"));
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 57 with DataDefinition

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

the class CrudIntegrationTest method shouldOrderDescEntities.

@Test
public void shouldOrderDescEntities() throws Exception {
    // given
    DataDefinition machineDataDefinition = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE);
    Entity machine1 = machineDataDefinition.save(createMachine("asd"));
    Entity machine2 = machineDataDefinition.save(createMachine("def"));
    // when
    List<Entity> machines = machineDataDefinition.find().addOrder(SearchOrders.asc("name")).list().getEntities();
    // then
    assertNotNull(machines);
    assertEquals(2, machines.size());
    assertEquals(machine1.getId(), machines.get(0).getId());
    assertEquals(machine2.getId(), machines.get(1).getId());
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 58 with DataDefinition

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

the class CrudIntegrationTest method shouldOrderAscEntities.

@Test
public void shouldOrderAscEntities() throws Exception {
    // given
    DataDefinition machineDataDefinition = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE);
    Entity machine1 = machineDataDefinition.save(createMachine("asd"));
    Entity machine2 = machineDataDefinition.save(createMachine("def"));
    // when
    List<Entity> machines = machineDataDefinition.find().addOrder(SearchOrders.desc("name")).list().getEntities();
    // then
    assertNotNull(machines);
    assertEquals(2, machines.size());
    assertEquals(machine2.getId(), machines.get(0).getId());
    assertEquals(machine1.getId(), machines.get(1).getId());
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 59 with DataDefinition

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

the class CrudIntegrationTest method shouldNotFindSoftDeletedEntities.

@Test
public void shouldNotFindSoftDeletedEntities() throws Exception {
    // given
    DataDefinition machineDataDefinition = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE);
    Entity machine1 = machineDataDefinition.save(createMachine("asd"));
    Entity machine2 = machineDataDefinition.save(createMachine("def"));
    machineDataDefinition.delete(machine1.getId());
    // when
    List<Entity> machines = machineDataDefinition.find().list().getEntities();
    // then
    assertNotNull(machines);
    assertEquals(1, machines.size());
    assertEquals(machine2.getId(), machines.get(0).getId());
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition) Test(org.junit.Test)

Example 60 with DataDefinition

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

the class CrudIntegrationTest method shouldHookUpdateReadOnlyFieldOnCreate.

@Test
public void shouldHookUpdateReadOnlyFieldOnCreate() throws Exception {
    // given
    DataDefinition productDataDefinition = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
    Entity product = createProduct("product", "18");
    // when
    product.setField("readOnly", "someValue");
    product = productDataDefinition.save(product);
    // then
    assertTrue(product.isValid());
    assertEquals("changedByHook", product.getField("readOnly"));
    Map<String, Object> result = jdbcTemplate.queryForMap("select * from " + TABLE_NAME_PRODUCT);
    assertNotNull(result);
    assertEquals("changedByHook", result.get("readOnly"));
}
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