### Question:
ResponseCreateGame extends Response { public static ResponseCreateGame from(Sc2Api.Response sc2ApiResponse) { if (!hasCreateGameResponse(sc2ApiResponse)) { throw new IllegalArgumentException("provided argument doesn't have create game response"); } return new ResponseCreateGame( sc2ApiResponse.getCreateGame(), sc2ApiResponse.getStatus(), sc2ApiResponse.getId()); } private  ResponseCreateGame(Sc2Api.ResponseCreateGame sc2ApiResponseCreateGame, Sc2Api.Status status, int id); static ResponseCreateGame from(Sc2Api.Response sc2ApiResponse); Optional<Error> getError(); Optional<String> getErrorDetails(); @Override boolean equals(Object o); @Override boolean canEqual(Object other); @Override int hashCode(); @Override String toString();  }### Answer:
@Test void throwsExceptionWhenSc2ApiResponseDoesNotHaveCreateGame() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ResponseCreateGame.from(nothing())) .withMessage("provided argument doesn't have create game response"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ResponseCreateGame.from(aSc2ApiResponse().build())) .withMessage("provided argument doesn't have create game response"); }
@Test void convertsSc2ApiResponseCreateGameToResponseCreateGame() { assertThatResponseCreateGameDoesNotHaveError(ResponseCreateGame.from(sc2ApiResponseWithCreateGame())); }
@Test void throwsExceptionWhenResponseCreateGameErrorIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ResponseCreateGame.Error.from(nothing())) .withMessage("sc2api response create game error is required"); }
@Test void convertsSc2ApiResponseCreateGameWithErrorToResponseCreateGame() { ResponseCreateGame responseCreateGame = ResponseCreateGame.from(sc2ApiResponseWithCreateGameWithError()); assertThatResponseIsInValidState(responseCreateGame); assertThatErrorsAreMapped(responseCreateGame); }