OverviewFactory { public JsonNode createQueued(Execution execution) { ObjectMapper mapper = new ObjectMapper(); ObjectNode rootNode = mapper.createObjectNode(); rootNode.set("@context", createContextForQueued(mapper)); rootNode.put("@id", execution.getIri() + "/overview"); ObjectNode executionNode = mapper.createObjectNode(); executionNode.put("@id", execution.getIri()); rootNode.set("execution", executionNode); ObjectNode statusNode = mapper.createObjectNode(); statusNode.put("@id", LP_EXEC.STATUS_QUEUED); rootNode.set("status", statusNode); ObjectNode pipelineNode = mapper.createObjectNode(); if (execution.getPipeline() != null) { pipelineNode.put("@id", execution.getPipeline().stringValue()); rootNode.set("pipeline", pipelineNode); } Date lastChange; if (execution.getLastOverviewChange() == null) { lastChange = new Date(); } else { lastChange = execution.getLastOverviewChange(); } rootNode.put("lastChange", dateFormat.format(lastChange)); return rootNode; }  JsonNode createDeleted(Execution execution, Date date); JsonNode createQueued(Execution execution);  }
@Test public void loadFromJsonQueued() { Execution execution = Mockito.mock(Execution.class); String iri = "http: Mockito.when(execution.getIri()).thenReturn(iri); Resource pipeline = SimpleValueFactory.getInstance().createIRI( "http: Mockito.when(execution.getPipeline()).thenReturn(pipeline); OverviewObject overview = OverviewObject.fromJson( overviewFactory.createQueued(execution)); Assert.assertEquals( ExecutionStatus.QUEUED.asStr(), overview.getStatus()); Assert.assertEquals(pipeline.stringValue(), overview.getPipeline()); }
@Test public void loadFromJsonQueuedNoPipeline() { Execution execution = Mockito.mock(Execution.class); String iri = "http: Date date = new Date(); Mockito.when(execution.getIri()).thenReturn(iri); Mockito.when(execution.getLastOverviewChange()).thenReturn(date); OverviewObject overview = OverviewObject.fromJson( overviewFactory.createQueued(execution)); Assert.assertEquals( ExecutionStatus.QUEUED.asStr(), overview.getStatus()); Assert.assertNull(overview.getPipeline()); Assert.assertEquals(date, overview.getLastChange()); }