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"));
}
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());
}
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());
}
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());
}
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"));
}
Aggregations