### Question:
ErrorResponse { static ErrorResponse fromMap(final Map<String, Object> errorResponseMap) { String reason; try { reason = (String) errorResponseMap.get("reason"); } catch (final ClassCastException e) { reason = null; } Instant timestamp; if (errorResponseMap.containsKey("timestamp")) { try { timestamp = Instant.ofEpochMilli((Long) errorResponseMap.get("timestamp")); } catch (final ClassCastException e) { timestamp = null; } } else { timestamp = null; } return new ErrorResponse(reason, timestamp); } ErrorResponse(final String reason, final Instant timestamp);   }### Answer:
@Test void fromMap() { { final ErrorResponse emptyError = ErrorResponse.fromMap(Collections.emptyMap()); assertNull(emptyError.getReason()); assertNull(emptyError.getTimestamp()); } { final String reason = "Badness"; final ErrorResponse reasonOnlyError = ErrorResponse.fromMap(Collections.singletonMap("reason", reason)); assertEquals(reason, reasonOnlyError.getReason()); assertNull(reasonOnlyError.getTimestamp()); } { final String reason = "Badness"; final Instant timestamp = Instant.now(); final Map<String, Object> errorResponseMap = new HashMap<>(); errorResponseMap.put("reason", reason); errorResponseMap.put("timestamp", timestamp.toEpochMilli()); final ErrorResponse errorResponse = ErrorResponse.fromMap(errorResponseMap); assertEquals(reason, errorResponse.getReason()); assertEquals(timestamp.toEpochMilli(), errorResponse.getTimestamp().toEpochMilli()); } { final Map<String, Object> wrongTypesErrorMap = new HashMap<>(); wrongTypesErrorMap.put("reason", 17); wrongTypesErrorMap.put("timestamp", false); final ErrorResponse errorResponse = ErrorResponse.fromMap(wrongTypesErrorMap); assertNull(errorResponse.getReason()); assertNull(errorResponse.getTimestamp()); } }