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