@Test public void testRun$failure$writeSessionAndTerminationFailure(@Mocked final WriteSession session, @Mocked final ResourceSnapshot snapshot) throws Exception { DynamicResourceHandler handler = new DynamicResourceHandler(); DynamicResourceResolver sut = writeSessionFailureWithTerminationFailureSut(handler,session,snapshot); sut.run(); verifyResult(snapshot,handler,true,true,"OK"); }
@Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); LOGGER.debug("Starting resolution process on {}...",new 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(snapshot.name(),snapshot.templateId())); SnapshotResolver snapshotResolver = SnapshotResolver. builder(). withReadSession(session). withCanonicalBase(CANONICAL_BASE). build(); URI snapshotEndpoint = snapshotResolver.toURI(snapshot); individual. addValue( SNAPSHOT_ENDPOINT, Literals.newLiteral(snapshotEndpoint)); individual. addValue( SNAPSHOT_RESOLUTION, Literals.newLiteral(roundtrip(snapshotResolver,snapshotEndpoint,snapshot))); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not resolve resource",e); } finally { LOGGER.debug("Finalized resolution process"); } }
DynamicResourceResolver implements Runnable { @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); LOGGER.debug("Starting resolution process on {}...",new 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(snapshot.name(),snapshot.templateId())); SnapshotResolver snapshotResolver = SnapshotResolver. builder(). withReadSession(session). withCanonicalBase(CANONICAL_BASE). build(); URI snapshotEndpoint = snapshotResolver.toURI(snapshot); individual. addValue( SNAPSHOT_ENDPOINT, Literals.newLiteral(snapshotEndpoint)); individual. addValue( SNAPSHOT_RESOLUTION, Literals.newLiteral(roundtrip(snapshotResolver,snapshotEndpoint,snapshot))); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not resolve resource",e); } finally { LOGGER.debug("Finalized resolution process"); } } }
DynamicResourceResolver implements Runnable { @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); LOGGER.debug("Starting resolution process on {}...",new 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(snapshot.name(),snapshot.templateId())); SnapshotResolver snapshotResolver = SnapshotResolver. builder(). withReadSession(session). withCanonicalBase(CANONICAL_BASE). build(); URI snapshotEndpoint = snapshotResolver.toURI(snapshot); individual. addValue( SNAPSHOT_ENDPOINT, Literals.newLiteral(snapshotEndpoint)); individual. addValue( SNAPSHOT_RESOLUTION, Literals.newLiteral(roundtrip(snapshotResolver,snapshotEndpoint,snapshot))); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not resolve resource",e); } finally { LOGGER.debug("Finalized resolution process"); } } DynamicResourceResolver(DynamicResourceHandler handler, Name<String> name); }
DynamicResourceResolver implements Runnable { @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); LOGGER.debug("Starting resolution process on {}...",new 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(snapshot.name(),snapshot.templateId())); SnapshotResolver snapshotResolver = SnapshotResolver. builder(). withReadSession(session). withCanonicalBase(CANONICAL_BASE). build(); URI snapshotEndpoint = snapshotResolver.toURI(snapshot); individual. addValue( SNAPSHOT_ENDPOINT, Literals.newLiteral(snapshotEndpoint)); individual. addValue( SNAPSHOT_RESOLUTION, Literals.newLiteral(roundtrip(snapshotResolver,snapshotEndpoint,snapshot))); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not resolve resource",e); } finally { LOGGER.debug("Finalized resolution process"); } } DynamicResourceResolver(DynamicResourceHandler handler, Name<String> name); @Override void run(); }
DynamicResourceResolver implements Runnable { @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); LOGGER.debug("Starting resolution process on {}...",new 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(snapshot.name(),snapshot.templateId())); SnapshotResolver snapshotResolver = SnapshotResolver. builder(). withReadSession(session). withCanonicalBase(CANONICAL_BASE). build(); URI snapshotEndpoint = snapshotResolver.toURI(snapshot); individual. addValue( SNAPSHOT_ENDPOINT, Literals.newLiteral(snapshotEndpoint)); individual. addValue( SNAPSHOT_RESOLUTION, Literals.newLiteral(roundtrip(snapshotResolver,snapshotEndpoint,snapshot))); this.handler.update(this.name, dataSet); session.modify(snapshot); session.saveChanges(); } catch (Exception e) { LOGGER.error("Could not resolve resource",e); } finally { LOGGER.debug("Finalized resolution process"); } } DynamicResourceResolver(DynamicResourceHandler handler, Name<String> name); @Override void run(); static final URI SNAPSHOT_RESOLUTION; static final URI SNAPSHOT_ENDPOINT; static final URI CANONICAL_BASE; }