@Test public void testRun(@Mocked final WriteSession session, @Mocked final ResourceSnapshot snapshot) throws Exception { DynamicResourceHandler handler = new DynamicResourceHandler(); DynamicResourceUpdater sut = workingSut(handler,session,snapshot); sut.run(); verifyResult(snapshot,handler,true); }
@Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); Date date = new Date(); LOGGER.debug("Starting update process on {}...",date); try(WriteSession session = ctx.createSession()) { ResourceSnapshot snapshot = session.find(ResourceSnapshot.class,this.name,DynamicResourceHandler.class); DataSet dataSet = this.handler.get(snapshot); Individual<?,?> individual = dataSet. individualOfId( ManagedIndividualId. createId(this.name, DynamicResourceHandler.ID)); individual. addValue( REFRESHED_ON, Literals.of(date).dateTime()); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not update resource",e); } finally { LOGGER.debug("Finalized update process"); } }
DynamicResourceUpdater implements Runnable { @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); Date date = new Date(); LOGGER.debug("Starting update process on {}...",date); try(WriteSession session = ctx.createSession()) { ResourceSnapshot snapshot = session.find(ResourceSnapshot.class,this.name,DynamicResourceHandler.class); DataSet dataSet = this.handler.get(snapshot); Individual<?,?> individual = dataSet. individualOfId( ManagedIndividualId. createId(this.name, DynamicResourceHandler.ID)); individual. addValue( REFRESHED_ON, Literals.of(date).dateTime()); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not update resource",e); } finally { LOGGER.debug("Finalized update process"); } } }
DynamicResourceUpdater implements Runnable { @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); Date date = new Date(); LOGGER.debug("Starting update process on {}...",date); try(WriteSession session = ctx.createSession()) { ResourceSnapshot snapshot = session.find(ResourceSnapshot.class,this.name,DynamicResourceHandler.class); DataSet dataSet = this.handler.get(snapshot); Individual<?,?> individual = dataSet. individualOfId( ManagedIndividualId. createId(this.name, DynamicResourceHandler.ID)); individual. addValue( REFRESHED_ON, Literals.of(date).dateTime()); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not update resource",e); } finally { LOGGER.debug("Finalized update process"); } } DynamicResourceUpdater(DynamicResourceHandler handler, Name<String> name); }
DynamicResourceUpdater implements Runnable { @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); Date date = new Date(); LOGGER.debug("Starting update process on {}...",date); try(WriteSession session = ctx.createSession()) { ResourceSnapshot snapshot = session.find(ResourceSnapshot.class,this.name,DynamicResourceHandler.class); DataSet dataSet = this.handler.get(snapshot); Individual<?,?> individual = dataSet. individualOfId( ManagedIndividualId. createId(this.name, DynamicResourceHandler.ID)); individual. addValue( REFRESHED_ON, Literals.of(date).dateTime()); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not update resource",e); } finally { LOGGER.debug("Finalized update process"); } } DynamicResourceUpdater(DynamicResourceHandler handler, Name<String> name); @Override void run(); }
DynamicResourceUpdater implements Runnable { @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); Date date = new Date(); LOGGER.debug("Starting update process on {}...",date); try(WriteSession session = ctx.createSession()) { ResourceSnapshot snapshot = session.find(ResourceSnapshot.class,this.name,DynamicResourceHandler.class); DataSet dataSet = this.handler.get(snapshot); Individual<?,?> individual = dataSet. individualOfId( ManagedIndividualId. createId(this.name, DynamicResourceHandler.ID)); individual. addValue( REFRESHED_ON, Literals.of(date).dateTime()); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not update resource",e); } finally { LOGGER.debug("Finalized update process"); } } DynamicResourceUpdater(DynamicResourceHandler handler, Name<String> name); @Override void run();  }