@Test public void shouldRequestDashboardComponents() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); restApiUnderTest.requestDashboardComponents("/my/uri"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request, containsHeader("Accept", "application/dashboardComponentsSchema+json")); assertThat(request, hasPath("/rest_v2/resources/my/uri_files/components?expanded=false")); assertThat(request, wasMethod("GET")); }
@NotNull public DashboardComponentCollection requestDashboardComponents(@NotNull String dashboardUri) throws IOException, HttpException { Utils.checkNotNull(dashboardUri, "Dashboard uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(dashboardUri + "_files") .addPath("components") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("expanded", "false") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/dashboardComponentsSchema+json") .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return mNetworkClient.deserializeJson(rawResponse, DashboardComponentCollection.class); }
RepositoryRestApi { @NotNull public DashboardComponentCollection requestDashboardComponents(@NotNull String dashboardUri) throws IOException, HttpException { Utils.checkNotNull(dashboardUri, "Dashboard uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(dashboardUri + "_files") .addPath("components") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("expanded", "false") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/dashboardComponentsSchema+json") .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return mNetworkClient.deserializeJson(rawResponse, DashboardComponentCollection.class); } }
RepositoryRestApi { @NotNull public DashboardComponentCollection requestDashboardComponents(@NotNull String dashboardUri) throws IOException, HttpException { Utils.checkNotNull(dashboardUri, "Dashboard uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(dashboardUri + "_files") .addPath("components") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("expanded", "false") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/dashboardComponentsSchema+json") .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return mNetworkClient.deserializeJson(rawResponse, DashboardComponentCollection.class); } RepositoryRestApi(NetworkClient networkClient); }
RepositoryRestApi { @NotNull public DashboardComponentCollection requestDashboardComponents(@NotNull String dashboardUri) throws IOException, HttpException { Utils.checkNotNull(dashboardUri, "Dashboard uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(dashboardUri + "_files") .addPath("components") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("expanded", "false") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/dashboardComponentsSchema+json") .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return mNetworkClient.deserializeJson(rawResponse, DashboardComponentCollection.class); } 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 DashboardComponentCollection requestDashboardComponents(@NotNull String dashboardUri) throws IOException, HttpException { Utils.checkNotNull(dashboardUri, "Dashboard uri should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("resources") .addPaths(dashboardUri + "_files") .addPath("components") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("expanded", "false") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/dashboardComponentsSchema+json") .get() .url(url) .build(); com.squareup.okhttp.Response rawResponse = mNetworkClient.makeCall(request); return mNetworkClient.deserializeJson(rawResponse, DashboardComponentCollection.class); } 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);  }