@Test public void shouldRequestFileContent() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); restApiUnderTest.requestResourceOutput("/my/uri"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request, hasPath("/rest_v2/resources/my/uri")); assertThat(request, wasMethod("GET")); }
@NotNull public OutputResource requestResourceOutput(@NotNull String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Resource uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(resourceUri) .build() .resolve(mNetworkClient.getBaseUrl()); Request request = new Request.Builder() .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return new RetrofitOutputResource(rawResponse.body()); }
RepositoryRestApi { @NotNull public OutputResource requestResourceOutput(@NotNull String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Resource uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(resourceUri) .build() .resolve(mNetworkClient.getBaseUrl()); Request request = new Request.Builder() .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return new RetrofitOutputResource(rawResponse.body()); } }
RepositoryRestApi { @NotNull public OutputResource requestResourceOutput(@NotNull String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Resource uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(resourceUri) .build() .resolve(mNetworkClient.getBaseUrl()); Request request = new Request.Builder() .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return new RetrofitOutputResource(rawResponse.body()); } RepositoryRestApi(NetworkClient networkClient); }
RepositoryRestApi { @NotNull public OutputResource requestResourceOutput(@NotNull String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Resource uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(resourceUri) .build() .resolve(mNetworkClient.getBaseUrl()); Request request = new Request.Builder() .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return new RetrofitOutputResource(rawResponse.body()); } RepositoryRestApi(NetworkClient networkClient); @NotNull ResourceSearchResult searchResources(@NotNull Map<String, Object> searchParams); @NotNull ResourceLookup requestResource(@NotNull String resourceUri, @NotNull String type); @NotNull DashboardComponentCollection requestDashboardComponents(@NotNull String dashboardUri); @NotNull OutputResource requestResourceOutput(@NotNull String resourceUri); }
RepositoryRestApi { @NotNull public OutputResource requestResourceOutput(@NotNull String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Resource uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(resourceUri) .build() .resolve(mNetworkClient.getBaseUrl()); Request request = new Request.Builder() .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return new RetrofitOutputResource(rawResponse.body()); } RepositoryRestApi(NetworkClient networkClient); @NotNull ResourceSearchResult searchResources(@NotNull Map<String, Object> searchParams); @NotNull ResourceLookup requestResource(@NotNull String resourceUri, @NotNull String type); @NotNull DashboardComponentCollection requestDashboardComponents(@NotNull String dashboardUri); @NotNull OutputResource requestResourceOutput(@NotNull String resourceUri);  }