@Test public void testUpdate() throws Exception { final WebResourceMetaInfo sourceDocumentReferenceMetaInfo = new WebResourceMetaInfo("a", new ImageMetaInfo(10, 10, "", "", "", null, null, null), null, null, null); webResourceMetaInfoDao.createOrModify(Lists.newArrayList(sourceDocumentReferenceMetaInfo), WriteConcern.ACKNOWLEDGED); final WebResourceMetaInfo updatedSourceDocumentReferenceMetaInfo = new WebResourceMetaInfo(sourceDocumentReferenceMetaInfo.getId(), new ImageMetaInfo(20, 20, "", "", "", null, null, null), null, null, null); assertNotEquals(updatedSourceDocumentReferenceMetaInfo.getImageMetaInfo().getHeight(), webResourceMetaInfoDao.read( sourceDocumentReferenceMetaInfo.getId()).getImageMetaInfo().getHeight()); assertTrue(webResourceMetaInfoDao.createOrModify(Lists.newArrayList(updatedSourceDocumentReferenceMetaInfo), WriteConcern.ACKNOWLEDGED) == 1); assertEquals(updatedSourceDocumentReferenceMetaInfo.getImageMetaInfo().getHeight(), webResourceMetaInfoDao.read( sourceDocumentReferenceMetaInfo.getId()).getImageMetaInfo().getHeight()); webResourceMetaInfoDao.delete(updatedSourceDocumentReferenceMetaInfo.getId()); final WebResourceMetaInfo checkUpdateSourceDocumentReferenceMetaInfo = new WebResourceMetaInfo("a", new ImageMetaInfo(20, 20, "", "", "", null, null, null), null, null, null); assertFalse(webResourceMetaInfoDao.createOrModify(Lists.newArrayList(checkUpdateSourceDocumentReferenceMetaInfo), WriteConcern.ACKNOWLEDGED) == 2); }
@Override public boolean update(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern) { if(read(webResourceMetaInfo.getId()) != null) { datastore.save(webResourceMetaInfo, writeConcern); return true; } return false; }
WebResourceMetaInfoDaoImpl implements WebResourceMetaInfoDao { @Override public boolean update(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern) { if(read(webResourceMetaInfo.getId()) != null) { datastore.save(webResourceMetaInfo, writeConcern); return true; } return false; } }
WebResourceMetaInfoDaoImpl implements WebResourceMetaInfoDao { @Override public boolean update(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern) { if(read(webResourceMetaInfo.getId()) != null) { datastore.save(webResourceMetaInfo, writeConcern); return true; } return false; } WebResourceMetaInfoDaoImpl(DB mongoDB,Morphia morphia,Datastore datastore); }
WebResourceMetaInfoDaoImpl implements WebResourceMetaInfoDao { @Override public boolean update(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern) { if(read(webResourceMetaInfo.getId()) != null) { datastore.save(webResourceMetaInfo, writeConcern); return true; } return false; } WebResourceMetaInfoDaoImpl(DB mongoDB,Morphia morphia,Datastore datastore); @Override boolean create(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern); @Override int createOrModify(Collection<WebResourceMetaInfo> webResourceMetaInfos, WriteConcern writeConcern); @Override WebResourceMetaInfo read(String id); @Override List<WebResourceMetaInfo> read(List<String> ids); @Override boolean update(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern); @Override WriteResult delete(String id); }
WebResourceMetaInfoDaoImpl implements WebResourceMetaInfoDao { @Override public boolean update(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern) { if(read(webResourceMetaInfo.getId()) != null) { datastore.save(webResourceMetaInfo, writeConcern); return true; } return false; } WebResourceMetaInfoDaoImpl(DB mongoDB,Morphia morphia,Datastore datastore); @Override boolean create(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern); @Override int createOrModify(Collection<WebResourceMetaInfo> webResourceMetaInfos, WriteConcern writeConcern); @Override WebResourceMetaInfo read(String id); @Override List<WebResourceMetaInfo> read(List<String> ids); @Override boolean update(WebResourceMetaInfo webResourceMetaInfo, WriteConcern writeConcern); @Override WriteResult delete(String id);  }