@Test public void testRegisterReturnsError() throws Exception { stubFor(post(urlPathEqualTo("/v2/user.create")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBodyFile("api-error.json"))); Result result = apiClient.register("username", "pwd", "name", "email@bob.com"); verify(postRequestedFor(urlPathEqualTo("/v2/user.create")) .withHeader("Content-Type", equalTo("application/x-www-form-urlencoded")) .withQueryParam("key", equalTo("myApiKey"))); assertThat(result.ok()).isFalse(); assertThat(result.message()).contains("Your account could not be registered."); }
public Result register(final String username, final String password, final String name, final String email) throws IOException { Response<UserCreateResponseDto> response = v2Api.register(username, password, name, email).execute(); return response.body().toRegistrationResult(); }
RetrofitApiClient { public Result register(final String username, final String password, final String name, final String email) throws IOException { Response<UserCreateResponseDto> response = v2Api.register(username, password, name, email).execute(); return response.body().toRegistrationResult(); } }
RetrofitApiClient { public Result register(final String username, final String password, final String name, final String email) throws IOException { Response<UserCreateResponseDto> response = v2Api.register(username, password, name, email).execute(); return response.body().toRegistrationResult(); } @SuppressWarnings("deprecation")  RetrofitApiClient(Builder builder); }
RetrofitApiClient { public Result register(final String username, final String password, final String name, final String email) throws IOException { Response<UserCreateResponseDto> response = v2Api.register(username, password, name, email).execute(); return response.body().toRegistrationResult(); } @SuppressWarnings("deprecation")  RetrofitApiClient(Builder builder); String getJourneyJson(final String plan,
                               final String itineraryPoints,
                               final String leaving,
                               final String arriving,
                               final int speed); String retrievePreviousJourneyJson(final String plan,
                                            final long itineraryId); Blog getBlogEntries(); POICategories getPOICategories(); List<POI> getPOIs(final String type,
                           final double lonW,
                           final double latS,
                           final double lonE,
                           final double latN); List<POI> getPOIs(final String type,
                           final double lon,
                           final double lat,
                           final int radius); GeoPlaces geoCoder(final String search,
                            final double lonW,
                            final double latS,
                            final double lonE,
                            final double latN); PhotomapCategories getPhotomapCategories(); Photos getPhotos(final double lonW,
                          final double latS,
                          final double lonE,
                          final double latN); Photos getPhoto(final long photoId); UserJourneys getUserJourneys(final String username); Result register(final String username,
                         final String password,
                         final String name,
                         final String email); Signin.Result authenticate(final String identifier,
                                    final String password); Result sendFeedback(final int itinerary,
                             final String comments,
                             final String name,
                             final String email); Upload.Result uploadPhoto(final String username,
                                   final String password,
                                   final double lon,
                                   final double lat,
                                   final long dateTime,
                                   final String category,
                                   final String metaCat,
                                   final String caption,
                                   final String filename); }
RetrofitApiClient { public Result register(final String username, final String password, final String name, final String email) throws IOException { Response<UserCreateResponseDto> response = v2Api.register(username, password, name, email).execute(); return response.body().toRegistrationResult(); } @SuppressWarnings("deprecation")  RetrofitApiClient(Builder builder); String getJourneyJson(final String plan,
                               final String itineraryPoints,
                               final String leaving,
                               final String arriving,
                               final int speed); String retrievePreviousJourneyJson(final String plan,
                                            final long itineraryId); Blog getBlogEntries(); POICategories getPOICategories(); List<POI> getPOIs(final String type,
                           final double lonW,
                           final double latS,
                           final double lonE,
                           final double latN); List<POI> getPOIs(final String type,
                           final double lon,
                           final double lat,
                           final int radius); GeoPlaces geoCoder(final String search,
                            final double lonW,
                            final double latS,
                            final double lonE,
                            final double latN); PhotomapCategories getPhotomapCategories(); Photos getPhotos(final double lonW,
                          final double latS,
                          final double lonE,
                          final double latN); Photos getPhoto(final long photoId); UserJourneys getUserJourneys(final String username); Result register(final String username,
                         final String password,
                         final String name,
                         final String email); Signin.Result authenticate(final String identifier,
                                    final String password); Result sendFeedback(final int itinerary,
                             final String comments,
                             final String name,
                             final String email); Upload.Result uploadPhoto(final String username,
                                   final String password,
                                   final double lon,
                                   final double lat,
                                   final long dateTime,
                                   final String category,
                                   final String metaCat,
                                   final String caption,
                                   final String filename);  }