WorkflowMetricsSLAProcessor { protected boolean isOnTime( Document document, LocalDateTime nowLocalDateTime, LocalDateTime overdueLocalDateTime) { if (nowLocalDateTime.isBefore(overdueLocalDateTime)) { return true; } LocalDateTime createDateLocalDateTime = LocalDateTime.parse( document.getDate("createDate"), _dateTimeFormatter); if (createDateLocalDateTime.isAfter(overdueLocalDateTime)) { return false; } if (Validator.isNull(document.getDate("completionDate"))) { return false; } LocalDateTime completionDateLocalDateTime = LocalDateTime.parse( document.getDate("completionDate"), _dateTimeFormatter); if (completionDateLocalDateTime.isBefore(overdueLocalDateTime) || Objects.equals(completionDateLocalDateTime, overdueLocalDateTime)) { return true; } return false; }  WorkflowMetricsSLAInstanceResult process(
		LocalDateTime completionLocalDateTime,
		LocalDateTime createLocalDateTime, List<Document> documents,
		long instanceId, LocalDateTime nowLocalDateTime, long startNodeId,
		WorkflowMetricsSLADefinitionVersion workflowMetricsSLADefinitionVersion,
		WorkflowMetricsSLAInstanceResult workflowMetricsSLAInstanceResult);  }
@Test public void testIsOnTime() { LocalDateTime nowLocalDateTime = _createLocalDateTime(); _assertIsOnTime( true, _createDocument( HashMapBuilder.<String, Object>put( "createDate", _format(nowLocalDateTime) ).build()), nowLocalDateTime, nowLocalDateTime.plusHours(1)); _assertIsOnTime( true, _createDocument( HashMapBuilder.<String, Object>put( "completionDate", _format(nowLocalDateTime.minusHours(1)) ).put( "createDate", _format(nowLocalDateTime.minusHours(2)) ).build()), nowLocalDateTime, nowLocalDateTime.minusHours(1)); _assertIsOnTime( false, _createDocument( HashMapBuilder.<String, Object>put( "createDate", _format(nowLocalDateTime.minusHours(1)) ).build()), nowLocalDateTime, nowLocalDateTime.minusHours(2)); _assertIsOnTime( false, _createDocument( HashMapBuilder.<String, Object>put( "createDate", _format(nowLocalDateTime.minusHours(2)) ).build()), nowLocalDateTime, nowLocalDateTime.minusHours(1)); _assertIsOnTime( false, _createDocument( HashMapBuilder.<String, Object>put( "completionDate", _format(nowLocalDateTime) ).put( "createDate", _format(nowLocalDateTime.minusHours(2)) ).build()), nowLocalDateTime, nowLocalDateTime.minusHours(1)); }