@Test public void apiShouldUpdateReportOption() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); Map<String, Set<String>> params = new HashMap<>(); params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("22")); restApiUnderTest.updateReportOption("/any/uri", "option_id", REPORT_PARAMS); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); assertThat(request.getMethod(), is("PUT")); }
public void updateReportOption( @NotNull String reportUnitUri, @NotNull String optionId, @NotNull List<ReportParameter> parameters) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(parameters, "Parameters values should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUnitUri) .addPath("options") .addPath(optionId) .build() .resolve(mNetworkClient.getBaseUrl()); Map<String, Set<String>> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); RequestBody requestBody = mNetworkClient.createJsonRequestBody(controlsValues); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(requestBody) .url(url) .build(); mNetworkClient.makeCall(request); }
ReportOptionRestApi { public void updateReportOption( @NotNull String reportUnitUri, @NotNull String optionId, @NotNull List<ReportParameter> parameters) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(parameters, "Parameters values should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUnitUri) .addPath("options") .addPath(optionId) .build() .resolve(mNetworkClient.getBaseUrl()); Map<String, Set<String>> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); RequestBody requestBody = mNetworkClient.createJsonRequestBody(controlsValues); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(requestBody) .url(url) .build(); mNetworkClient.makeCall(request); } }
ReportOptionRestApi { public void updateReportOption( @NotNull String reportUnitUri, @NotNull String optionId, @NotNull List<ReportParameter> parameters) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(parameters, "Parameters values should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUnitUri) .addPath("options") .addPath(optionId) .build() .resolve(mNetworkClient.getBaseUrl()); Map<String, Set<String>> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); RequestBody requestBody = mNetworkClient.createJsonRequestBody(controlsValues); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(requestBody) .url(url) .build(); mNetworkClient.makeCall(request); } ReportOptionRestApi(NetworkClient networkClient); }
ReportOptionRestApi { public void updateReportOption( @NotNull String reportUnitUri, @NotNull String optionId, @NotNull List<ReportParameter> parameters) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(parameters, "Parameters values should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUnitUri) .addPath("options") .addPath(optionId) .build() .resolve(mNetworkClient.getBaseUrl()); Map<String, Set<String>> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); RequestBody requestBody = mNetworkClient.createJsonRequestBody(controlsValues); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(requestBody) .url(url) .build(); mNetworkClient.makeCall(request); } ReportOptionRestApi(NetworkClient networkClient); @NotNull Set<ReportOptionEntity> requestReportOptionsList(
            @NotNull String reportUnitUri); @NotNull ReportOptionEntity createReportOption(
            @NotNull String reportUnitUri,
            @NotNull String optionLabel,
            @NotNull List<ReportParameter> parameters,
            boolean overwrite); void updateReportOption(
            @NotNull String reportUnitUri,
            @NotNull String optionId,
            @NotNull List<ReportParameter> parameters); void deleteReportOption(
            @Nullable String reportUnitUri,
            @Nullable String optionId); }
ReportOptionRestApi { public void updateReportOption( @NotNull String reportUnitUri, @NotNull String optionId, @NotNull List<ReportParameter> parameters) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(parameters, "Parameters values should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUnitUri) .addPath("options") .addPath(optionId) .build() .resolve(mNetworkClient.getBaseUrl()); Map<String, Set<String>> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); RequestBody requestBody = mNetworkClient.createJsonRequestBody(controlsValues); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(requestBody) .url(url) .build(); mNetworkClient.makeCall(request); } ReportOptionRestApi(NetworkClient networkClient); @NotNull Set<ReportOptionEntity> requestReportOptionsList(
            @NotNull String reportUnitUri); @NotNull ReportOptionEntity createReportOption(
            @NotNull String reportUnitUri,
            @NotNull String optionLabel,
            @NotNull List<ReportParameter> parameters,
            boolean overwrite); void updateReportOption(
            @NotNull String reportUnitUri,
            @NotNull String optionId,
            @NotNull List<ReportParameter> parameters); void deleteReportOption(
            @Nullable String reportUnitUri,
            @Nullable String optionId);  }