No effective change - Add test for undo of soft deleted bean

This commit is contained in:
Robin Bygrave
2016-05-06 13:38:09 +12:00
parent e9e1a975f9
commit 2797f6bbcc
2 changed files with 38 additions and 0 deletions
@@ -49,6 +49,10 @@ public class Cover extends Model {
return this.deleted;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
public Long getId() {
return this.id;
}
@@ -10,6 +10,8 @@ import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
public class DeleteById_SoftDelete_Tests {
@@ -30,6 +32,38 @@ public class DeleteById_SoftDelete_Tests {
cover.deletePermanent();
}
@Test
public void undo_softDelete() {
Cover cover = new Cover("b1");
cover.save();
Ebean.delete(Cover.class, cover.getId());
Cover findWhenSoft = Ebean.find(Cover.class, cover.getId());
assertNull(findWhenSoft);
Cover cover1 = Ebean.find(Cover.class)
.setIncludeSoftDeletes()
.setId(cover.getId())
.findUnique();
cover1.setDeleted(false);
LoggedSqlCollector.start();
cover1.update();
List<String> sql = LoggedSqlCollector.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains("update cover set deleted=? where id=?; --bind(false");
Cover findAgain = Ebean.find(Cover.class, cover.getId());
assertNotNull(findAgain);
cover.deletePermanent();
}
@Test
public void deleteById_when_softDelete() {