@Test public void testCaseQueryNotClosedAsPost() { List<HistoricCaseInstance> mockedHistoricCaseInstances = MockProvider.createMockRunningHistoricCaseInstances(); HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class); when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances); when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery); Map<String, Boolean> body = new HashMap<String, Boolean>(); body.put("notClosed", true); Response response = given() .contentType(POST_JSON_CONTENT_TYPE) .body(body) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedHistoricCaseInstanceQuery); inOrder.verify(mockedHistoricCaseInstanceQuery).notClosed(); inOrder.verify(mockedHistoricCaseInstanceQuery).list(); String content = response.asString(); List<String> instances = from(content).getList(""); Assert.assertEquals(1, instances.size()); Assert.assertNotNull(instances.get(0)); String returnedCaseInstanceId = from(content).getString("[0].id"); String returnedCloseTime = from(content).getString("[0].closeTime"); Assert.assertEquals(MockProvider.EXAMPLE_CASE_INSTANCE_ID, returnedCaseInstanceId); Assert.assertEquals(null, returnedCloseTime); }
@Test public void testCaseQueryNotClosed() { List<HistoricCaseInstance> mockedHistoricCaseInstances = MockProvider.createMockRunningHistoricCaseInstances(); HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class); when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances); when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery); Response response = given() .queryParam("notClosed", true) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedHistoricCaseInstanceQuery); inOrder.verify(mockedHistoricCaseInstanceQuery).notClosed(); inOrder.verify(mockedHistoricCaseInstanceQuery).list(); String content = response.asString(); List<String> instances = from(content).getList(""); Assert.assertEquals(1, instances.size()); Assert.assertNotNull(instances.get(0)); String returnedCaseInstanceId = from(content).getString("[0].id"); String returnedCloseTime = from(content).getString("[0].closeTime"); Assert.assertEquals(MockProvider.EXAMPLE_CASE_INSTANCE_ID, returnedCaseInstanceId); Assert.assertEquals(null, returnedCloseTime); }
assertCount(1, historicQuery().notClosed()); assertTrue(historicCaseInstance.isCompleted()); assertCount(1, historicQuery().completed()); assertCount(1, historicQuery().notClosed()); assertTrue(historicCaseInstance.isTerminated()); assertCount(1, historicQuery().terminated()); assertCount(1, historicQuery().notClosed()); assertCount(1, historicQuery().notClosed()); assertTrue(historicCaseInstance.isClosed()); assertCount(1, historicQuery().closed()); assertCount(0, historicQuery().notClosed());
assertCount(1, historicQuery().notClosed()); assertTrue(historicCaseInstance.isCompleted()); assertCount(1, historicQuery().completed()); assertCount(1, historicQuery().notClosed()); assertTrue(historicCaseInstance.isTerminated()); assertCount(1, historicQuery().terminated()); assertCount(1, historicQuery().notClosed()); assertCount(1, historicQuery().notClosed()); assertTrue(historicCaseInstance.isClosed()); assertCount(1, historicQuery().closed()); assertCount(0, historicQuery().notClosed());