@Test public void delete() throws ModelException { DBCollection spaces = Database.getCollection("spaces"); assertEquals(0, spaces.count()); Space space = new Space(); space._id = new ObjectId(); space.name = "Test space"; space.owner = new ObjectId(); space.visualization = new ObjectId(); space.order = 1; space.records = new HashSet<ObjectId>(); Space.add(space); assertEquals(1, spaces.count()); Space.delete(space.owner, space._id); assertEquals(0, spaces.count()); }
@Test public void notExists() throws ModelException { DBCollection spaces = Database.getCollection("spaces"); assertEquals(0, spaces.count()); Space space = new Space(); space._id = new ObjectId(); space.name = "Test space"; space.owner = new ObjectId(); space.visualization = new ObjectId(); space.order = 1; space.records = new HashSet<ObjectId>(); Space.add(space); assertEquals(1, spaces.count()); assertFalse( Space.exists( new ChainedMap<String, ObjectId>() .put("_id", new ObjectId()) .put("owner", space.owner) .get())); }
@After public void tearDown() { Database.close(); }
@Before public void setUp() { start(fakeApplication(fakeGlobal())); Database.connectToTest(); Database.destroy(); }