@Test public void convertMultipleTimestampingServiceDiagnostics() { final OffsetDateTime prevUpdate = OffsetDateTime.now(); final OffsetDateTime prevUpdate2 = prevUpdate.plusSeconds(60); DiagnosticsStatus diagnosticsStatus1 = new DiagnosticsStatus(DiagnosticsErrorCodes.ERROR_CODE_INTERNAL, prevUpdate); diagnosticsStatus1.setDescription(URL_1); DiagnosticsStatus diagnosticsStatus2 = new DiagnosticsStatus(DiagnosticsErrorCodes.ERROR_CODE_TIMESTAMP_UNINITIALIZED, prevUpdate2); diagnosticsStatus2.setDescription(URL_2); List<DiagnosticsStatus> list = new ArrayList<>(Arrays.asList(diagnosticsStatus1, diagnosticsStatus2)); List<TimestampingServiceDiagnostics> timestampingServiceDiagnostics = timestampingServiceDiagnosticConverter .convert(list); assertEquals(2, timestampingServiceDiagnostics.size()); assertEquals(URL_1, timestampingServiceDiagnostics.get(0).getUrl()); assertEquals(TimestampingStatus.ERROR_CODE_INTERNAL, timestampingServiceDiagnostics.get(0).getStatusCode()); assertEquals(DiagnosticStatusClass.FAIL, timestampingServiceDiagnostics.get(0).getStatusClass()); assertEquals(prevUpdate, timestampingServiceDiagnostics.get(0).getPrevUpdateAt()); assertEquals(URL_2, timestampingServiceDiagnostics.get(1).getUrl()); assertEquals(TimestampingStatus.ERROR_CODE_TIMESTAMP_UNINITIALIZED, timestampingServiceDiagnostics.get(1) .getStatusCode()); assertEquals(DiagnosticStatusClass.WAITING, timestampingServiceDiagnostics.get(1).getStatusClass()); assertEquals(prevUpdate2, timestampingServiceDiagnostics.get(1).getPrevUpdateAt()); }
public TimestampingServiceDiagnostics convert(DiagnosticsStatus diagnosticsStatus) { TimestampingServiceDiagnostics timestampingServiceDiagnostics = new TimestampingServiceDiagnostics(); timestampingServiceDiagnostics.setUrl(diagnosticsStatus.getDescription()); Optional<TimestampingStatus> statusCode = TimestampingStatusMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusCode(statusCode.orElse(null)); Optional<DiagnosticStatusClass> statusClass = DiagnosticStatusClassMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusClass(statusClass.orElse(null)); if (diagnosticsStatus.getPrevUpdate() != null) { timestampingServiceDiagnostics.setPrevUpdateAt(diagnosticsStatus.getPrevUpdate()); } return timestampingServiceDiagnostics; }
TimestampingServiceDiagnosticConverter { public TimestampingServiceDiagnostics convert(DiagnosticsStatus diagnosticsStatus) { TimestampingServiceDiagnostics timestampingServiceDiagnostics = new TimestampingServiceDiagnostics(); timestampingServiceDiagnostics.setUrl(diagnosticsStatus.getDescription()); Optional<TimestampingStatus> statusCode = TimestampingStatusMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusCode(statusCode.orElse(null)); Optional<DiagnosticStatusClass> statusClass = DiagnosticStatusClassMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusClass(statusClass.orElse(null)); if (diagnosticsStatus.getPrevUpdate() != null) { timestampingServiceDiagnostics.setPrevUpdateAt(diagnosticsStatus.getPrevUpdate()); } return timestampingServiceDiagnostics; } }
TimestampingServiceDiagnosticConverter { public TimestampingServiceDiagnostics convert(DiagnosticsStatus diagnosticsStatus) { TimestampingServiceDiagnostics timestampingServiceDiagnostics = new TimestampingServiceDiagnostics(); timestampingServiceDiagnostics.setUrl(diagnosticsStatus.getDescription()); Optional<TimestampingStatus> statusCode = TimestampingStatusMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusCode(statusCode.orElse(null)); Optional<DiagnosticStatusClass> statusClass = DiagnosticStatusClassMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusClass(statusClass.orElse(null)); if (diagnosticsStatus.getPrevUpdate() != null) { timestampingServiceDiagnostics.setPrevUpdateAt(diagnosticsStatus.getPrevUpdate()); } return timestampingServiceDiagnostics; }  }
TimestampingServiceDiagnosticConverter { public TimestampingServiceDiagnostics convert(DiagnosticsStatus diagnosticsStatus) { TimestampingServiceDiagnostics timestampingServiceDiagnostics = new TimestampingServiceDiagnostics(); timestampingServiceDiagnostics.setUrl(diagnosticsStatus.getDescription()); Optional<TimestampingStatus> statusCode = TimestampingStatusMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusCode(statusCode.orElse(null)); Optional<DiagnosticStatusClass> statusClass = DiagnosticStatusClassMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusClass(statusClass.orElse(null)); if (diagnosticsStatus.getPrevUpdate() != null) { timestampingServiceDiagnostics.setPrevUpdateAt(diagnosticsStatus.getPrevUpdate()); } return timestampingServiceDiagnostics; }  TimestampingServiceDiagnostics convert(DiagnosticsStatus diagnosticsStatus); List<TimestampingServiceDiagnostics> convert(Iterable<DiagnosticsStatus> statuses); }
TimestampingServiceDiagnosticConverter { public TimestampingServiceDiagnostics convert(DiagnosticsStatus diagnosticsStatus) { TimestampingServiceDiagnostics timestampingServiceDiagnostics = new TimestampingServiceDiagnostics(); timestampingServiceDiagnostics.setUrl(diagnosticsStatus.getDescription()); Optional<TimestampingStatus> statusCode = TimestampingStatusMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusCode(statusCode.orElse(null)); Optional<DiagnosticStatusClass> statusClass = DiagnosticStatusClassMapping.map( diagnosticsStatus.getReturnCode()); timestampingServiceDiagnostics.setStatusClass(statusClass.orElse(null)); if (diagnosticsStatus.getPrevUpdate() != null) { timestampingServiceDiagnostics.setPrevUpdateAt(diagnosticsStatus.getPrevUpdate()); } return timestampingServiceDiagnostics; }  TimestampingServiceDiagnostics convert(DiagnosticsStatus diagnosticsStatus); List<TimestampingServiceDiagnostics> convert(Iterable<DiagnosticsStatus> statuses);  }