### Question:
ResponseJoinGame extends Response { public static ResponseJoinGame from(Sc2Api.Response sc2ApiResponse) { if (!hasJoinGameResponse(sc2ApiResponse)) { throw new IllegalArgumentException("provided argument doesn't have join game response"); } return new ResponseJoinGame(sc2ApiResponse.getJoinGame(), sc2ApiResponse.getStatus(), sc2ApiResponse.getId()); } private  ResponseJoinGame(Sc2Api.ResponseJoinGame sc2ApiResponseJoinGame, Sc2Api.Status sc2ApiStatus, int id); static ResponseJoinGame from(Sc2Api.Response sc2ApiResponse); Optional<Error> getError(); Optional<String> getErrorDetails(); Integer getPlayerId(); @Override boolean equals(Object o); @Override boolean canEqual(Object other); @Override int hashCode(); @Override String toString();  }### Answer:
@Test void throwsExceptionWhenSc2ApiResponseDoesNotHaveJoinGame() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ResponseJoinGame.from(nothing())) .withMessage("provided argument doesn't have join game response"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ResponseJoinGame.from(aSc2ApiResponse().build())) .withMessage("provided argument doesn't have join game response"); }
@Test void convertsSc2ApiResponseJoinGameToResponseJoinGame() { assertThatResponseJoinGameDoesNotHaveError(ResponseJoinGame.from(sc2ApiResponseWithJoinGame())); }
@Test void throwsExceptionWhenResponseJoinGameErrorIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ResponseJoinGame.Error.from(nothing())) .withMessage("sc2api response join game error is required"); }
@Test void convertsSc2ApiResponseJoinGameWithErrorToResponseJoinGame() { ResponseJoinGame responseJoinGame = ResponseJoinGame.from(sc2ApiResponseWithJoinGameWithError()); assertThatResponseIsInValidState(responseJoinGame); assertThatErrorsAreMapped(responseJoinGame); }