@After public void after() throws DatastoreException { if (dboBasicDao != null) { // delete submission MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("id", submissionId); dboBasicDao.deleteObjectByPrimaryKey(SubmissionDBO.class, params); // delete participant params = new MapSqlParameterSource(); params.addValue("userId", userId); params.addValue("evalId", evalId); dboBasicDao.deleteObjectByPrimaryKey(ParticipantDBO.class, params); // delete Evaluation params = new MapSqlParameterSource(); params.addValue("id", evalId); dboBasicDao.deleteObjectByPrimaryKey(EvaluationDBO.class, params); } try { nodeDAO.delete(nodeId); } catch (NotFoundException e) { } ; }
@Test public void testCRUD() throws Exception { // Initialize a new SubmissionStatus object for submissionId SubmissionStatusDBO status = new SubmissionStatusDBO(); status.setId(submissionId); status.seteTag(eTag); status.setModifiedOn(System.currentTimeMillis()); status.setStatusEnum(SubmissionStatusEnum.OPEN); status.setScore(0.0); status.setSerializedEntity("foo".getBytes()); // Create it SubmissionStatusDBO clone = dboBasicDao.createNew(status); assertNotNull(clone); assertEquals(status, clone); // Fetch it MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("id", submissionId); SubmissionStatusDBO clone2 = dboBasicDao.getObjectByPrimaryKey(SubmissionStatusDBO.class, params); assertEquals(status, clone2); // Update it clone2.setStatusEnum(SubmissionStatusEnum.SCORED); clone2.setScore(0.9); dboBasicDao.update(clone2); SubmissionStatusDBO clone3 = dboBasicDao.getObjectByPrimaryKey(SubmissionStatusDBO.class, params); assertEquals(clone2, clone3); // Delete it boolean result = dboBasicDao.deleteObjectByPrimaryKey(SubmissionStatusDBO.class, params); assertTrue("Failed to delete the entry created", result); }