}
@Test
public void testEntity2NoBindingCascading() {
City city = null;
Entity2 entity2 = null;
try {
entity2 = new Entity2();
Params params = new Params();
params.put("entity2.a", "testNewEntity2");
params.put("entity2.b", "true");
params.put("entity2.c", "1");
city = new City();
city.name = "Name";
city.save();
params.put("entity2.city.id", city.getId().toString());
params.put("entity2.city.name", "changeNameOfA");
params.put("entity2.cities.id", city.getId().toString());
Validation.clear();
ParamNode rootParamNode = ParamNode.convert(params.all());
entity2.edit(rootParamNode, "entity2");
assertFalse(Validation.hasErrors());
entity2.save();
assertEquals("testNewEntity2", entity2.a);
assertEquals(true, entity2.b);
assertEquals(1, entity2.c);
assertEquals(city.getId(), entity2.city.id);
assertEquals("changeNameOfA", entity2.city.name);
assertNotNull(entity2.cities);
assertEquals(1, entity2.cities.size());
assertEquals(city.name, entity2.cities.get(0).name);
// Check that modification Company has not been save
City dbCity = City.findById(city.getId());
// Refresh to avoid cash issue
dbCity.refresh();
assertEquals(city.name, dbCity.name);
assertNotEquals("changeNameOfA", dbCity.name);
assertEquals("Name", dbCity.name);
} finally {
if (entity2 != null && entity2.id != null) {
entity2.delete();
}
if (city != null && city.id != null) {
city.delete();
}
}