use of com.qcadoo.model.api.types.EnumeratedType in project qcadoo by qcadoo.
the class ModuleIntegrationTest method shouldNotCallAdditionalHooksIfPluginIsDisabledOnlyForCurrentTenant.
@Test
public void shouldNotCallAdditionalHooksIfPluginIsDisabledOnlyForCurrentTenant() throws Exception {
// given
pluginManager.enablePlugin(PLUGIN_MACHINES_NAME);
DataDefinition machineDao = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE);
machineDao.save(createMachine("asd"));
PluginStateResolver pluginStateResolver = mock(PluginStateResolver.class);
PluginUtilsService pluginUtil = new PluginUtilsService(pluginStateResolver);
pluginUtil.init();
given(pluginStateResolver.isEnabled(PLUGIN_MACHINES_NAME)).willReturn(false);
given(pluginStateResolver.isEnabledOrEnabling(PLUGIN_MACHINES_NAME)).willReturn(false);
DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
DataDefinition componentDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_COMPONENT);
Entity product = createProduct("asd", "asd");
product.setField("changeableName", "xxx");
product = productDao.save(product);
Entity component = createComponent("name", product, null);
component.setField("machineName", "test");
// when
component = componentDao.save(component);
// then
assertEquals("xxx", product.getField("changeableName"));
assertNotNull(component.getField("machineName"));
assertNull(component.getField("machine"));
Map<String, Object> componentResult = jdbcTemplate.queryForMap("select * from " + TABLE_NAME_COMPONENT);
assertNotNull(componentResult);
assertNotNull(componentResult.get("machineName"));
Map<String, Object> productResult = jdbcTemplate.queryForMap("select * from " + TABLE_NAME_PRODUCT);
assertNotNull(productResult);
assertEquals("xxx", productResult.get("changeableName"));
assertThat(((EnumeratedType) productDao.getField("enum").getType()).activeValues(Locale.ENGLISH).keySet(), JUnitMatchers.hasItems("one", "two"));
}
use of com.qcadoo.model.api.types.EnumeratedType in project qcadoo by qcadoo.
the class ModuleIntegrationTest method shouldNotHaveAdditionalFieldsAndHooks.
@Test
public void shouldNotHaveAdditionalFieldsAndHooks() throws Exception {
// given
DataDefinition machineDao = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE);
machineDao.save(createMachine("asd"));
pluginManager.disablePlugin(PLUGIN_MACHINES_NAME);
DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
DataDefinition componentDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_COMPONENT);
Entity product = createProduct("asd", "asd");
product.setField("changeableName", "xxx");
product = productDao.save(product);
Entity component = createComponent("name", product, null);
component.setField("machineName", "test");
// when
component = componentDao.save(component);
// then
assertEquals("xxx", product.getField("changeableName"));
assertNull(component.getField("machineName"));
assertNull(component.getField("machine"));
Map<String, Object> componentResult = jdbcTemplate.queryForMap("select * from " + TABLE_NAME_COMPONENT);
assertNotNull(componentResult);
assertNull(componentResult.get("machineName"));
Map<String, Object> productResult = jdbcTemplate.queryForMap("select * from " + TABLE_NAME_PRODUCT);
assertNotNull(productResult);
assertEquals("xxx", productResult.get("changeableName"));
assertThat(((EnumeratedType) productDao.getField("enum").getType()).activeValues(Locale.ENGLISH).keySet(), JUnitMatchers.hasItems("one", "two"));
}
use of com.qcadoo.model.api.types.EnumeratedType in project qcadoo by qcadoo.
the class ModuleIntegrationTest method shouldCallAdditionalHooksIfPluginIsEnabledForCurrentTenant.
@Test
public void shouldCallAdditionalHooksIfPluginIsEnabledForCurrentTenant() 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);
Entity machine = machineDao.save(createMachine("asd"));
Entity product = createProduct("asd", "asd");
product.setField("changeableName", "xxx");
product = productDao.save(product);
Entity component = createComponent("name", product, machine);
component.setField("machineName", "test");
// when
component = componentDao.save(component);
// then
assertEquals("test", component.getField("machineName"));
assertEquals("XXX", product.getField("changeableName"));
assertNotNull(component.getField("machine"));
Map<String, Object> componentResult = jdbcTemplate.queryForMap("select * from " + TABLE_NAME_COMPONENT);
assertNotNull(componentResult);
assertEquals("test", componentResult.get("machineName"));
Map<String, Object> productResult = jdbcTemplate.queryForMap("select * from " + TABLE_NAME_PRODUCT);
assertNotNull(productResult);
assertEquals("XXX", productResult.get("changeableName"));
assertThat(((EnumeratedType) productDao.getField("enum").getType()).activeValues(Locale.ENGLISH).keySet(), JUnitMatchers.hasItems("one", "two", "three"));
}
Aggregations