use of com.qcadoo.model.api.EntityOpResult in project qcadoo by qcadoo.
the class ManyToManyIntegrationTest method shouldPerformCascadeDeletion.
@Test
public final void shouldPerformCascadeDeletion() {
// given
Entity firstProduct = save(createProduct("asd", "00001"));
Entity secondProduct = save(createProduct("fgh", "00002"));
Entity thirdProduct = save(createProduct("jkl", "00003"));
Entity anotherProduct = save(createProduct("qwertyuiop", "00004"));
Entity firstPart = save(createPart("qwe", anotherProduct, Lists.newArrayList(firstProduct, secondProduct)));
Entity secondPart = save(createPart("rty", anotherProduct, Lists.newArrayList(firstProduct, thirdProduct)));
Entity thirdPart = save(createPart("uiop", anotherProduct, Lists.newArrayList(firstProduct, secondProduct, thirdProduct)));
// when
EntityOpResult result = delete(secondProduct);
// then
Assert.assertTrue(result.isSuccessfull());
Assert.assertNull(fromDb(firstPart));
Assert.assertNotNull(fromDb(secondPart));
Assert.assertNull(fromDb(thirdPart));
Assert.assertNotNull(fromDb(firstProduct));
Assert.assertNull(fromDb(secondProduct));
Assert.assertNotNull(fromDb(thirdProduct));
}
Aggregations