@Test public void toProblemForNakadi645() { Response response = buildReponse(TestSupport.load("nakadi-645-invalid-problem-401.json"), 401); Problem problem = ProblemSupport.toProblem(response, jsonSupport); assertEquals("token_assumed_unauthorized", problem.title()); assertEquals(401, problem.status()); response = buildReponse(TestSupport.load("nakadi-645-invalid-problem-400.json"), 400); problem = ProblemSupport.toProblem(response, jsonSupport); assertEquals("token_assumed_unauthorized", problem.title()); assertEquals(401, problem.status()); }
static Problem toProblem(Response response, JsonSupport jsonSupport) { final String raw = response.responseBody().asString(); Problem problem = jsonSupport.fromJson(raw, Problem.class); if (problem == null) { problem = Problem.noProblemo("no problem sent back from server", "", response.statusCode()); } if (problem.status() == 0 && (response.statusCode() == 400 || response.statusCode() == 401)) { if (raw.contains("\"error_description\"")) { problem = Problem.authProblem("token_assumed_unauthorized", "Inferred from invalid response there was an auth issue, " + "see https: } } problem = Optional.ofNullable(problem) .orElse(Problem.noProblemo("no problem sent back from server", "", response.statusCode())); return problem; }
ProblemSupport { static Problem toProblem(Response response, JsonSupport jsonSupport) { final String raw = response.responseBody().asString(); Problem problem = jsonSupport.fromJson(raw, Problem.class); if (problem == null) { problem = Problem.noProblemo("no problem sent back from server", "", response.statusCode()); } if (problem.status() == 0 && (response.statusCode() == 400 || response.statusCode() == 401)) { if (raw.contains("\"error_description\"")) { problem = Problem.authProblem("token_assumed_unauthorized", "Inferred from invalid response there was an auth issue, " + "see https: } } problem = Optional.ofNullable(problem) .orElse(Problem.noProblemo("no problem sent back from server", "", response.statusCode())); return problem; } }
ProblemSupport { static Problem toProblem(Response response, JsonSupport jsonSupport) { final String raw = response.responseBody().asString(); Problem problem = jsonSupport.fromJson(raw, Problem.class); if (problem == null) { problem = Problem.noProblemo("no problem sent back from server", "", response.statusCode()); } if (problem.status() == 0 && (response.statusCode() == 400 || response.statusCode() == 401)) { if (raw.contains("\"error_description\"")) { problem = Problem.authProblem("token_assumed_unauthorized", "Inferred from invalid response there was an auth issue, " + "see https: } } problem = Optional.ofNullable(problem) .orElse(Problem.noProblemo("no problem sent back from server", "", response.statusCode())); return problem; }  }
ProblemSupport { static Problem toProblem(Response response, JsonSupport jsonSupport) { final String raw = response.responseBody().asString(); Problem problem = jsonSupport.fromJson(raw, Problem.class); if (problem == null) { problem = Problem.noProblemo("no problem sent back from server", "", response.statusCode()); } if (problem.status() == 0 && (response.statusCode() == 400 || response.statusCode() == 401)) { if (raw.contains("\"error_description\"")) { problem = Problem.authProblem("token_assumed_unauthorized", "Inferred from invalid response there was an auth issue, " + "see https: } } problem = Optional.ofNullable(problem) .orElse(Problem.noProblemo("no problem sent back from server", "", response.statusCode())); return problem; }   }
ProblemSupport { static Problem toProblem(Response response, JsonSupport jsonSupport) { final String raw = response.responseBody().asString(); Problem problem = jsonSupport.fromJson(raw, Problem.class); if (problem == null) { problem = Problem.noProblemo("no problem sent back from server", "", response.statusCode()); } if (problem.status() == 0 && (response.statusCode() == 400 || response.statusCode() == 401)) { if (raw.contains("\"error_description\"")) { problem = Problem.authProblem("token_assumed_unauthorized", "Inferred from invalid response there was an auth issue, " + "see https: } } problem = Optional.ofNullable(problem) .orElse(Problem.noProblemo("no problem sent back from server", "", response.statusCode())); return problem; }    }