@Test public void integrationTestMarkCallAsBogus() throws Exception { missedCallsDAO = new MissedCallsDAO(Resources.getDatabaseActivity()); DBObject bogusCall = new BasicDBObject("who", 1234567890L); try { assertTrue(missedCallsDAO.insertCall(bogusCall)); assertEquals("Pending", bogusCall.get("state")); missedCallsDAO.setState(bogusCall, "Processing"); bogusCall = refetchCall(bogusCall); missedCallsDAO.setState(bogusCall, "Bogus"); assertEquals("Bogus", refetchCall(bogusCall).get("state")); } finally { deleteCall(bogusCall); } }
@Test public void testSetState() throws Exception { WriteResult response = mock(WriteResult.class); when(response.getN()).thenReturn(1); when(missedCalls.update(any(DBObject.class), any(DBObject.class))).thenReturn(response); assertTrue(missedCallsDAO.setState(new BasicDBObject("state", "Processing"), "Bogus")); verify(missedCalls, times(1)).update(any(DBObject.class), any(DBObject.class)); }